Скачать презентацию Рекурсия Факториал include stdio h include conio h Скачать презентацию Рекурсия Факториал include stdio h include conio h

C-2cem.ppt

  • Количество слайдов: 61

Рекурсия. Факториал #include <stdio. h> #include <conio. h> int fact(int n) { return n-1? Рекурсия. Факториал #include #include int fact(int n) { return n-1? n*fact(n-1): 1; } main() { int n; printf("n. Введи N: "); scanf("%d", &n); printf("%d", fact(n)); getch(); } Числа Фибоначчи. (1, 1, 2, 3, 5, 8…) #include #include int f(int n) { if(n<3) return 1; return f(n-1)+f(n-2); } main() { int i, n; clrscr(); printf("n Введите N: "); scanf("%d", &n); for(i=1; i<=n; i++) printf(" %d", f(i)); getch(); }

Рекурсия. Ханойские башни #include <stdio. h> #include <conio. h> int l=1; void hanoi(int n, Рекурсия. Ханойские башни #include #include int l=1; void hanoi(int n, int otkuda, int sred) { if(n>0){ hanoi(n-1, otkuda, sred, kuda); printf("n %d перенести диск cо стержня %d на стержень %d", l++, otkuda, kuda); hanoi(n-1, sred, kuda, otkuda); } } main() { int n; clrscr(); printf("n. Введите N: "); scanf("%d", &n); hanoi(n, 1, 3, 2); getch(); } Введите N: 4 1 перенести диск со стержня 1 на стержень 2 2 перенести диск со стержня 1 на стержень 3 3 перенести диск со стержня 2 на стержень 3 4 перенести диск со стержня 1 на стержень 2 5 перенести диск со стержня 3 на стержень 1 6 перенести диск со стержня 3 на стержень 2 7 перенести диск со стержня 1 на стержень 2 8 перенести диск со стержня 1 на стержень 3 9 перенести диск со стержня 2 на стержень 3 10 перенести диск со стержня 2 на стержень 1 11 перенести диск со стержня 3 на стержень 1 12 перенести диск со стержня 2 на стержень 3 13 перенести диск со стержня 1 на стержень 2 14 перенести диск со стержня 1 на стержень 3 15 перенести диск со стержня 2 на стержень 3

Рекурсия. Ханойские башни 1 2 3 Рекурсия. Ханойские башни 1 2 3

Стек Добавить New =(struct stack *)malloc(sizeof(struct stack)); New -> m = n; New -> Стек Добавить New =(struct stack *)malloc(sizeof(struct stack)); New -> m = n; New -> next = a; a= New; Удалить old=a; if(old) { n = old -> m; a = old -> next; } free(old); return n;

#include<conio. h> #include<alloc. h> Стек /* #include <malloc. h> для c++ */ struct stack{ #include #include Стек /* #include для c++ */ struct stack{ int m; struct stack *next; }*a; int pop() { struct stack *old=a; int n; if(old) { printf("n Извлечение из стека "); n=old->m; a=old->next; free (old); } else { printf("n Стек пуст"); return -10000; } return n; } void push(int n) { struct stack *New; New=(struct stack *) malloc(sizeof(struct stack)); New->m=n; New->next=a; a=New; } void out() { struct stack *temp; temp=a; printf(" n Сейчас в стеке "); while(temp) { printf(" %d ", temp->m); temp=temp->next; } }

Стек main () { clrscr(); push(1); push(2); printf( Стек main () { clrscr(); push(1); push(2); printf(" %d push(3); out(); printf(" %d push(4); push(5); ", pop()); out(); while (a) printf(" %d ", pop()); getch(); }

Очередь Очередь

Очередь #include <stdio. h> #include <alloc. h> /* #include <malloc. h> для c++ */ Очередь #include #include /* #include для c++ */ struct q{ int n; struct q *sled; } *s=0, *end=0; void qw(int n) { struct q *New; New=(struct q *) malloc(sizeof(struct q)); New->n=n; if(s) { end->sled=New; end=New; } else { s=New; end=New; } end->sled=0; } int pop() { struct q *old=s; int n; if(old) { n=old->n; s=old->sled; free(old); } else { printf("n Очередь пуста! "); n=0; } return n; }

Очередь main() { int i; qw(10); qw(101); qw(102); { struct q *np=s; while(np){ printf( Очередь main() { int i; qw(10); qw(101); qw(102); { struct q *np=s; while(np){ printf("%d ", np->n); np=np->sled; } printf("nn"); } for(i=0; i<5; i++) printf("%d ", pop(s)); getch(); }

Очередь #include <stdio. h> #include <alloc. h> /* #include <malloc. h> для c++ */ Очередь #include #include /* #include для c++ */ struct q{ int n; struct q *sled; }; void qw(struct q **s, struct q **end, int n) { struct q *New; New=(struct q *) malloc(sizeof(struct q)); New->n=n; if(*s) { (*end)->sled=New; *end=New; } else { *s=New; *end=New; } (*end)->sled=0; } int pop(struct q **s) { struct q *old=*s; int n; if(old) { n=old->n; *s=old->sled; free(old); } else { printf("n. Очередь пуста!"); n=0; } return n; }

Очередь main() { struct q *s=0, *end=0; int i; qw(&s, &end, 10); qw(&s, &end, Очередь main() { struct q *s=0, *end=0; int i; qw(&s, &end, 10); qw(&s, &end, 101); qw(&s, &end, 102); { struct q *np=s; while(np){ printf("%d ", np->n); np=np->sled; } printf("nn"); } for(i=0; i<5; i++) printf("%d ", pop(&s)); getch(); }

Вставка элемента в список (при внешнем описании) void vstavka(char* fio) { struct sp *New, Вставка элемента в список (при внешнем описании) void vstavka(char* fio) { struct sp *New, *nt, *z=0; int i; for(nt=spisok; nt!=0 && strcmp(nt->fio, fio)<0; z=nt, nt=nt->sled); if(nt && strcmp(nt->fio, fio)==0) return; New=(struct sp *) malloc(sizeof(struct sp)); strcpy(New->fio, fio); New->sled=nt; if(!z) spisok=New; else z->sled=New; }

Удаление из списка char fam[]=”Петров”; struct sp *z=0, *nt=spisok; while(nt && strcmp(nt->fam, fam)) {z=nt; Удаление из списка char fam[]=”Петров”; struct sp *z=0, *nt=spisok; while(nt && strcmp(nt->fam, fam)) {z=nt; nt=nt->sled; } if(nt){ if(z) z->sled = nt->sled; else spisok = nt->sled; free(nt); } else printf("Элемент не обнаружен!");

Двусторонний список Двусторонний список

Вставка элемента в двусторонний список (при внутреннем описании) void vstavka (struct sp **s, char Вставка элемента в двусторонний список (при внутреннем описании) void vstavka (struct sp **s, char *slovo) { struct sp *New, *nt, *z=0; for(nt=*s; nt!=0&&strcmp(nt->fam, slovo)<0; z=nt, nt=nt->sled); if(nt && strcmp(nt->fam, slovo)==0) return; New=(struct sp *)malloc(sizeof(struct sp)); strcpy(New->fam, slovo); New->pred=z; New->sled=nt; if(!z) *s=New; if(z) z->sled=New; if(nt) nt->pred=New; }

Вставка элемента в двусторонний список (при внутреннем описании) struct sp { char fam[20]; struct Вставка элемента в двусторонний список (при внутреннем описании) struct sp { char fam[20]; struct sp *pred; struct sp *sled; }; main() { FILE *in; struct sp *stud, *nt; char slovo[20]; if((in=fopen("spisok", "r"))==NULL){ printf("n. Файл spisok не открыт. "); exit(1); } stud=0; for( ; ; ) /* бесконечный цикл для ввода данных*/ if(fscanf(in, "%s", slovo)==EOF) break; else vstavka(&stud, slovo); for(nt=stud; nt!=0; nt=nt->sled) printf(" %s ", nt->fam); /* печать списка */ }

Дерево struct d { int n; struct d *lev, *pr; }; void dprint(struct d Дерево struct d { int n; struct d *lev, *pr; }; void dprint(struct d *p) struct d *derevo(struct d *p, int w) { { if(p){ if(!p) dprint(p->lev); { printf("%d ", p->n); p=(struct d *)malloc(sizeof(struct d)); dprint(p->pr); p->n=w; p->lev=p->pr=NULL; } } } else if(w-p->n<0) p->lev=derevo(p->lev, w); else p->pr=derevo(p->pr, w); return p; }

Дерево #include<stdio. h> #include<alloc. h> /* #include <malloc. h> для c++ */ struct d{ Дерево #include #include /* #include для c++ */ struct d{ int n; struct d *lev, *pr; }; main() { int n; struct d *root=0, *derevo(struct d *, int); printf("Задайте числа, для окончания -1n"); while(1){ scanf("%d", &n); if(n==-1)break; root=derevo(root, n); } dprint(root); /* печать дерева */ getch(); }

НЕКОТОРЫЕ ФУНКЦИИ ТЕКСТОВОГО РЕЖИМА 1 -й байт (8 бит) МФ ОН Ц В Е НЕКОТОРЫЕ ФУНКЦИИ ТЕКСТОВОГО РЕЖИМА 1 -й байт (8 бит) МФ ОН Ц В Е Т 2 -й байт (8 бит) AS CI I к о д N I R G B Color Код Символ 0 0 0 BLACK 0 1 0 0 0 1 BLUE 8 BACKSPACE 2 0 0 1 0 GREEN 13 Enter 3 0 0 1 1 CYAN 27 ESC 4 0 1 0 0 RED 32 пробел 5 0 1 MAGENTA 48 0 6 0 1 1 0 BROWN 49 1 7 0 1 1 1 LIGTHGRAY 65 A 8 1 0 0 0 DARKGRAY 90 Z 9 1 0 0 1 LIGTHBLUE 97 a 10 1 0 LIGTHGREEN 128 А 11 1 0 1 1 LIGTHCYAN 180 а 12 1 1 0 0 LIGTHRED 0+72 UP 13 1 1 0 1 LIGTHMAGENTA 0+75 LEFT 14 1 1 1 0 YELLOW 0+77 RIGHT 15 1 1 WHITE 0+80 DOWN

НЕКОТОРЫЕ ФУНКЦИИ ТЕКСТОВОГО РЕЖИМА window(int x 1, int y 1, int x 2, int НЕКОТОРЫЕ ФУНКЦИИ ТЕКСТОВОГО РЕЖИМА window(int x 1, int y 1, int x 2, int y 2) kbhit() getch() X=1 Y=1 Э К Р А Н getche() textcolor(int color) X=80 Y=25 textbackground(int color) window(1, 1, 80, 25); textattr(16*ФОН+СИМВОЛ) textattr(16*3+0); clrscr() /* clreol() textattr(16*CYAN+BLACK); wherex() */ wherey() clrscr(); gotoxy(int x, int y) gotoxy(36, 12); cprinrf(…) cprintf(”Э К Р А Н”);

Программирование меню char dan[7][55]= { Программирование меню char dan[7][55]= { "Какой вкладчик имеет на счету наибольшую сумму денег ? ", "Какой вклад был открыт раньше всех ? ", "Список "Срочных" вкладов с суммой свыше 10 000 р. ", "Алфавитный список всех вкладчиков ", "Количество вкладов "До востребования" ", "Диаграмма. Процентное соотношение вложенных денег ", "Выход " }; while (1) { textattr(LIGHTGRAY); window(1, 1, 80, 25); clrscr(); gotoxy(15, 2); cprintf("Выберите вопрос при помощи стрелок и нажмите ENTER"); window(10, 7, 70, 15); textbackground(LIGHTGRAY); clrscr(); textcolor(BLACK); cprintf("n"); for(i=0; i<7; i++) cprintf(" %snr", dan[i]);

Программирование меню n=menu(7); switch(n){ case case } } 1: 2: 3: 4: 5: 6: Программирование меню n=menu(7); switch(n){ case case } } 1: 2: 3: 4: 5: 6: 7: F 1(); break; F 2(); break; F 3(); break; F 4(); break; F 5(); break; F 6(); break; exit(0);

Программирование меню int menu(int n) { int y=0; char c=1; while (c!=ESC) { gotoxy(4, Программирование меню int menu(int n) { int y=0; char c=1; while (c!=ESC) { gotoxy(4, 2+y); textattr(16*LIGHTGRAY+BLACK); cprintf(dan[y]); switch(c) { case DOWN : y++; break; case UP : y--; break; case ENTER: return y+1; } if(y>n-1)y=0; if(y<0)y=n-1; gotoxy(4, 2+y); textattr(16*BLUE+WHITE); cprintf(dan[y]); c=getch(); } exit(0); }

#include #include" src="https://present5.com/presentation/12877143_132269841/image-26.jpg" alt="MS VISUAL C/C++ 2008 #include "stdafx. h" #include #include #include" /> MS VISUAL C/C++ 2008 #include "stdafx. h" #include #include #include using namespace std; using namespace System: : IO; int main() {. . . setlocale(LC_CTYPE, "Russian"); Console: : Cursor. Visible: : set(false); // Невидимый курсор Console: : Buffer. Height=Console: : Window. Height; //отключить Console: : Buffer. Width=Console: : Window. Width; //прокрутку экрана Console: : Foreground. Color=Console. Color: : Gray; Console: : Background. Color=Console. Color: : Black; Console: : Clear(); Console: : Cursor. Left=10; // столбец 1. . 80 Console: : Cursor. Top=4; // строка 1. . 25 printf(. . . );

#include #include #include" src="https://present5.com/presentation/12877143_132269841/image-27.jpg" alt="Программирование меню #include "stdafx. h" #include #include #include #include" /> Программирование меню #include "stdafx. h" #include #include #include #include using namespace std; using namespace System: : IO; #define ENTER 13 #define ESC 27 #define UP 72 #define DOWN 80 char dan[7][55]={ "Какой вкладчик имеет на счету наибольшую сумму денег ? ", "Какой вклад был открыт раньше всех ? ", "Список "Срочных" вкладов с суммой свыше 10 000 р. ", "Алфавитный список всех вкладчиков ", "Количество вкладов "До востребования" ", "Диаграмма. Процентное соотношение вложенных денег ", "Выход “ };

Программирование меню int menu(int n) {char c=1; int y 1=0, y 2=n-1; while (c!=ESC) Программирование меню int menu(int n) {char c=1; int y 1=0, y 2=n-1; while (c!=ESC) { switch(c) { case DOWN: y 2=y 1; y 1++; break; case UP: y 2=y 1; y 1 --; break; case ENTER: return y 1+1; } if(y 1>n-1){y 2=n-1; y 1=0; } if(y 1<0) {y 2=0; y 1=n-1; } Console: : Foreground. Color=Console. Color: : White; Console: : Background. Color=Console. Color: : Blue; Console: : Cursor. Left=11; Console: : Cursor. Top=y 1+5; printf(dan[y 1]); Console: : Foreground. Color=Console. Color: : Black; Console: : Background. Color=Console. Color: : Gray; Console: : Cursor. Left=11; Console: : Cursor. Top=y 2+5; printf(dan[y 2]); c=getch(); } // конец while(c!=ESC). . . exit(0); }

Программирование меню int main(array<System: : String ^> ^args) { int i, n; setlocale(LC_CTYPE, Программирование меню int main(array ^args) { int i, n; setlocale(LC_CTYPE, "Russian"); Console: : Cursor. Visible: : set(false); while(1) { Console: : Clear(); Console: : Foreground. Color=Console. Color: : Black; Console: : Background. Color=Console. Color: : Gray; for(i=0; i<7; i++) { Console: : Cursor. Left=10; Console: : Cursor. Top=i+5; cout<

Программирование меню n=menu(7); switch(n){ case case } 1: 2: 3: 4: 5: 6: 7: Программирование меню n=menu(7); switch(n){ case case } 1: 2: 3: 4: 5: 6: 7: /*maxim(clients); */ break; /*first(clients); */ break; /*listing(clients); */ break; /*alfalist(clients); */ break; /*new_punkt(clients); */ break; /*diagram(clients); */ break; exit(0); Console: : Foreground. Color=Console. Color: : Yellow; Console: : Background. Color=Console. Color: : Black; Console: : Cursor. Left=10; Console: : Cursor. Top=20; cout<<"Выбран: "<

Программирование меню Программирование меню

НЕКОТОРЫЕ ФУНКЦИИ ГРАФИЧЕСКОГО РЕЖИМА int gr=0, gm; /* gr=9 gm=2 640 x 480 16 НЕКОТОРЫЕ ФУНКЦИИ ГРАФИЧЕСКОГО РЕЖИМА int gr=0, gm; /* gr=9 gm=2 640 x 480 16 цв. 1 стр. */ /* gr=9 gm=1 640 x 350 16 цв. 2 стр. */ /* gr=9 gm=0 640 x 200 16 цв. 4 стр. */ initgraph(&gr, &gm, ""); /*EGAVGA. BGI*/ closegraph(); getaspectratio(int *x, int *y); getmaxx(); getmaxy(); getmaxcolor(); cleardevice(); setviewport(int x 1, int y 1, int x 2, int y 2, int clip); clearviewport(); setcolor(int color); setbkcolor(int color); getcolor(); getbkcolor(); getx(); gety(); moveto(int x, int y); putpixel(int x, int y, int color) ; getpixel(int x, int y);

НЕКОТОРЫЕ ФУНКЦИИ ГРАФИЧЕСКОГО РЕЖИМА setwritemode(int mode) 0 – COPY_PUT 1 - XOR_PUT setlinestyle(int style, НЕКОТОРЫЕ ФУНКЦИИ ГРАФИЧЕСКОГО РЕЖИМА setwritemode(int mode) 0 – COPY_PUT 1 - XOR_PUT setlinestyle(int style, unsigned upattern, int thickness); 0 – SOLID_LINE 1 - DOTTED_LINE 2 – CENTER_LINE 3 – DASHED_LINE 4 – USERBIT_LINE setfillstyle(int pattern, int color); 0 1 2 3. – – –. EMPTY_FILL SOLID_FILL LINE_FILL LTSLASH_FILL.

НЕКОТОРЫЕ ФУНКЦИИ ГРАФИЧЕСКОГО РЕЖИМА settextstyle(int font, int direction, int charsize) 0 – DEFAULT_FONT 0 НЕКОТОРЫЕ ФУНКЦИИ ГРАФИЧЕСКОГО РЕЖИМА settextstyle(int font, int direction, int charsize) 0 – DEFAULT_FONT 0 - HORIZ_DIR 1 – VERT_DIR 1 – 8 x 8 2 – 16 x 16 settextjustify(int horiz, int vert); 0 – 1 2 – LEFT_TEXT BOTTOM_TEXT CENTER_TEXT RIGHT_TEXT TOP_TEXT outtextxy(int x, int y, char *txt);

Контурные примитивы line(int x 1, int y 1, int x 2, int y 2); Контурные примитивы line(int x 1, int y 1, int x 2, int y 2); linerel(int dx, int dy); lineto(int x, int y); rectangle(int left, int top, int right, int bottom); drawpoly(int n, int *xy); circle(int x, int y, int r); arc(int x, int y, int startangle, int endangle, int r); ellipse(int x, int y, int startangle, int endangle, int xr, int yr);

Площадные примитивы bar(int left, int top, int right, int bottom); bar 3 d(int left, Площадные примитивы bar(int left, int top, int right, int bottom); bar 3 d(int left, int top, int right, int bottom, int depth, int topflag); fillpoly(int n, int *xy); fillellipse(int x, int y, int xr, int yr); pieslice(int x, int y, int startangle, int endangle, int r); sector(int x, int y, int startangle, int endangle, int xr, int yr); floodfill(int x, int y, int border);

Пример 1 #include <graphics. h> #include <conio. h> int main() { int gr=0, gm; Пример 1 #include #include int main() { int gr=0, gm; initgraph(&gr, &gm, ""); setfillstyle(SOLID_FILL, WHITE); rectangle(100, 300, 200); floodfill(200, 150, WHITE); /*bar(100, 300, 200); */ setcolor(LIGHTBLUE); setlinestyle(SOLID_LINE, 0, 3); line(100, 300, 200); line(100, 200, 300, 100); getch(); closegraph(); }

Пример 2 #include <conio. h> #include <graphics. h> #include <math. h> #define N 3 Пример 2 #include #include #include #define N 3 void turn(int x 0, int y 0, int alfa, int x, int y, int* x 1, int* y 1) { float t; t=alfa*M_PI/180; *x 1=x 0+(x-x 0)*cos(t)+(y-y 0)*sin(t); *y 1=y 0 -(x-x 0)*sin(t)+(y-y 0)*cos(t); return; }

Пример 2 (продолжение) int { int int main() gr=0, gm, a, i; Xc=125, Yc=150; Пример 2 (продолжение) int { int int main() gr=0, gm, a, i; Xc=125, Yc=150; /* середина гипотенузы */ xy[2*(N+1)], xy 1[2*(N+1)], /* Треугольник */ x[N]={100, 150}, y[N]={100, 200}; xy[2*N]=x[0]; xy[2*N+1]=y[0]; for(i=0; i

Пример 2 (продолжение) setcolor(WHITE); drawpoly(N+1, xy); getch(); for(a=360; a>0; a-=15) { setcolor(BLACK); drawpoly(N+1, xy); Пример 2 (продолжение) setcolor(WHITE); drawpoly(N+1, xy); getch(); for(a=360; a>0; a-=15) { setcolor(BLACK); drawpoly(N+1, xy); for(i=0; i

Пример 2 Пример 2

Курсовая работа #include <stdio. h> #include <string. h> VKLAD. DAT #include <alloc. h> ===== Курсовая работа #include #include VKLAD. DAT #include ===== /* для c++ */ 12 #include Иванов_А_А Срочный 15000 2002 -09 -23 #include Сидоров_И_А Юбилейный 7150 1991 -03 -08 #include Петров_В_Н Пенсионный 38876 1999 -12 -16 #define ENTER 13 Сидоров_И_А Сберегательный 12860 2008 -06 -23 #define ESC 27 Юдин_О_В Особый 25000 2006 -12 -13 #define UP 72 Федоров_М_К До_востребования 8905 2005 -11 -14 #define DOWN 80 Иванов_А_А Пенсионный 75980 2003 -08 -04 struct z { Сидоров_И_А Особый 34760 2004 -02 -07 char name[20]; Андреев_В_Н До_востребования 13908 2007 -04 -09 char vid[20]; Астафьева_Н_О Срочный 14500 2006 -11 -15 long summa; Иванов_А_А До_востребования 23900 2005 -05 -05 char data[11]; Лукьянова_А_В Срочный 8700 1998 -09 -08 }; struct sp { char fio[20]; long summa; struct sp* sled; } *spisok; char str[]="Для продолжения работы нажмите любую клавишу. . . "; int NC;

Курсовая работа char dan[7][55]= { Курсовая работа char dan[7][55]= { "Какой вкладчик имеет на счету наибольшую сумму денег ? ", "Какой вклад был открыт раньше всех ? ", "Список "Срочных" вкладов с суммой свыше 10 000 р. ", "Алфавитный список всех вкладчиков ", "Количество вкладов "До востребования" ", "Диаграмма. Процентное соотношение вложенных денег ", "Выход " }; int menu(int); void maxim(struct z*); void first(struct z*); void text_data(char *, char *); void kolvo(struct z *); void alfalist(struct z*); void vstavka(struct z*, char*); void listing(struct z*); void diagram(struct z*); Void press();

Курсовая работа main() void press() { { FILE *in; window(1, 1, 80, 25); struct Курсовая работа main() void press() { { FILE *in; window(1, 1, 80, 25); struct z *clients; gotoxy(18, 24); int n, next=1, i; textattr(LIGHTGRAY); if((in=fopen("vklad. dat", "r"))==NULL) cputs(str); { getch(); printf("n. Файл vklad. dat не открыт !"); getch(); exit(1); } } window(1, 1, 80, 25); textattr(LIGHTGRAY); clrscr(); fscanf(in, "%d", &NC); clients=(struct z*)malloc(NC*sizeof(struct z)); for(i=0; i

Курсовая работа while (next) { textattr(LIGHTGRAY); window(1, 1, 80, 25); clrscr(); gotoxy(15, 2); cprintf( Курсовая работа while (next) { textattr(LIGHTGRAY); window(1, 1, 80, 25); clrscr(); gotoxy(15, 2); cprintf("Выберите вопрос при помощи стрелок и нажмите ENTER"); window(10, 7, 70, 15); textbackground(LIGHTGRAY); clrscr(); textcolor(BLACK); cprintf("n"); for(i=0; i<7; i++) cprintf(" %snr", dan[i]); n=menu(7); switch(n){ case 1: maxim(clients); break; case 2: first(clients); break; case 3: listing(clients); break; case 4: alfalist(clients); break; case 5: kolvo(clients); break; case 6: diagram(clients); break; case 7: next=0; } } } /* конец main() */

Курсовая работа int menu(int n) { int y=0; char c=’�01’; while (c!=ESC) { gotoxy(4, Курсовая работа int menu(int n) { int y=0; char c=’01’; while (c!=ESC) { gotoxy(4, 2+y); textattr(16*LIGHTGRAY+BLACK); cprintf(dan[y]); switch(c) { case DOWN : y++; break; case UP : y--; break; case ENTER: return y+1; } if(y>n-1)y=0; if(y<0)y=n-1; gotoxy(4, 2+y); textattr(16*BLUE+WHITE); cprintf(dan[y]); c=getch(); } exit(0); }

Курсовая работа void maxim(struct z* client) { int i=0; struct z best; strcpy(best. name, Курсовая работа void maxim(struct z* client) { int i=0; struct z best; strcpy(best. name, client[0]. name); best. summa=client[0]. summa; for(i=1; ibest. summa) { strcpy(best. name, client[i]. name); best. summa=client[i]. summa; } window(23, 17, 58, 22); textbackground(CYAN); clrscr(); textcolor(MAGENTA); cprintf("nr Максимальный вклад"); cprintf("nr %ld рублей", best. summa); cprintf("nr имеет вкладчик"); cprintf("nr %s", best. name); press(); }

Курсовая работа void first(struct z* client) { int i; char s[17], sd[11]; struct z* Курсовая работа void first(struct z* client) { int i; char s[17], sd[11]; struct z* best=client; for(i=1; idata)<0) best=&client[i]; text_data(s, best->data); window(23, 17, 58, 22); textbackground(CYAN); clrscr(); textcolor(MAGENTA); cprintf("nr Самый "старый" вклад "); cprintf("nr %s на %ld р. ", best->vid, best->summa); cprintf("nr имеет вкладчик %s", best->name); cprintf("nr Открыт %s ", s); press(); }

Курсовая работа sd=” 1991 -03 -08” void text_data(char *s, char *sd) { char s Курсовая работа sd=” 1991 -03 -08” void text_data(char *s, char *sd) { char s 0[3], month[12][9]={"января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября", "декабря"}; strcpy(s, sd+8); strcat(s, " "); strncpy(s 0, sd+5, 2); s 0[2]=0; strcat(s, month[atoi(s 0)-1]); strcat(s, " "); strncat(s, sd, 4); return; } s="08" s="08 " s 0="03" s="08 марта 1991"

Курсовая работа void kolvo(struct z *client) { int i, k=0; for(i=0; i<NC; i++) if Курсовая работа void kolvo(struct z *client) { int i, k=0; for(i=0; i

Курсовая работа void alfalist(struct z* client) { int i; struct sp* nt; char fio[20]; Курсовая работа void alfalist(struct z* client) { int i; struct sp* nt; char fio[20]; if(!spisok) for(i=0; isled) printf("n %-20 s %ld", nt->fio, nt->summa); press(); }

Курсовая работа void vstavka(struct z* client, char* fio) { struct sp *New, *nt, *z=0; Курсовая работа void vstavka(struct z* client, char* fio) { struct sp *New, *nt, *z=0; int i; for(nt=spisok; nt!=0 && strcmp(nt->fio, fio)<0; z=nt, nt=nt->sled); if(nt && strcmp(nt->fio, fio)==0) return; New=(struct sp *) malloc(sizeof(struct sp)); strcpy(New->fio, fio); New->sled=nt; New->summa=0; for(i=0; isumma+=client[i]. summa; if(!z) spisok=New; else z->sled=New; }

Курсовая работа void listing(struct z* client) { int i; struct z* nt; window(1, 1, Курсовая работа void listing(struct z* client) { int i; struct z* nt; window(1, 1, 80, 25); textattr(LIGHTGRAY); clrscr(); cprintf("nr Список "Срочных" вкладов с суммой свыше 10 тыс. рублей"); cprintf("nr ===========================nr"); for(i=0, nt=client; isumma>10000 && strcmp(nt->vid, "Срочный")==0) cprintf("nr %-20 s %ld р. ", nt->name, nt->summa); press(); }

Курсовая работа void diagram(struct z *client) { struct sp *nt; int NSp, i=9, ii=1, Курсовая работа void diagram(struct z *client) { struct sp *nt; int NSp, i=9, ii=1, gr 1=0, gr 2, k, xr, yr; float t; long x=0, l, j=0, sum=0; char str 2[20], str 1[20]; for(k=0; ksled) NSp++; initgraph(&gr 1, &gr 2 , ""); cleardevice(); setcolor(WHITE); for(nt=spisok, k=0; nt!=0; nt=nt->sled, k++) { sprintf(str 1, "%s", nt->fio); sprintf(str 2, "%3. 1 f%%", (nt->summa*100. /sum)); settextstyle(0, 0, 1);

Курсовая работа if(i==16){i=9; ii++; } settextjustify(LEFT_TEXT, TOP_TEXT); setcolor(WHITE); outtextxy(470, k*15+20, str 1); setfillstyle(ii, i); Курсовая работа if(i==16){i=9; ii++; } settextjustify(LEFT_TEXT, TOP_TEXT); setcolor(WHITE); outtextxy(470, k*15+20, str 1); setfillstyle(ii, i); bar(440, k*15+18, 460, k*15+28); x=x+nt->summa; l=360*x/sum; if(k==(NSp-1)) l=360; t=360. 0*j/sum; setcolor(BLACK); pieslice(200, (int)t, (int)l, 100); t=(t+l)/2*3. 14/180; xr=200+125*cos(t); yr=200 -125*sin(t); settextjustify(CENTER_TEXT, CENTER_TEXT); setcolor(WHITE); outtextxy(xr, yr, str 2); j=x; i++; } getch(); closegraph(); return ; }

Курсовая работа Курсовая работа

Применение двоичного файла для хранения исходных данных. А) Чтение данных из текстового файла и Применение двоичного файла для хранения исходных данных. А) Чтение данных из текстового файла и запись в двоичный файл. FILE *in, *out; . . . in=fopen("Vklad. dat", "r"); out=fopen("Vklad. Bin. dat", "wb"); fscanf(in, "%d", &NC); clients=(struct z*)malloc(NC*sizeof(struct z)); for(i=0; i

Применение двоичного файла для хранения исходных данных. Б) Чтение из двоичного файла FILE *out; Применение двоичного файла для хранения исходных данных. Б) Чтение из двоичного файла FILE *out; . . . in=fopen("Vklad. Bin. dat", "rb"); fread(&NC, sizeof(int), 1, in); clients=(struct z*)malloc(NC*sizeof(struct z)); fread(clients, sizeof(struct z), NC, in); fclose(in);

Пример С++ #include <stdio. h> #include <conio. h> #include <iostream. h> int main() { Пример С++ #include #include #include int main() { int i, n; cout << "Введите n" << endl; // cin >> n; int *x; x= new int [n]; for(i=0; i

1. Пример С++ #include <stdio. h> #include <conio. h> #include <iostream. h> int main() 1. Пример С++ #include #include #include int main() { int i, n; cout << "Введите n" << endl; // cin >> n; int *x; x= new int [n]; for(i=0; i

2. Пример С++ #include <stdio. h> #include <conio. h> #include <fstream. h> int main() 2. Пример С++ #include #include #include int main() { int i, n; cout << "Введите n" << endl; // cin >> n; int *x; x= new int [n]; fstream f("x. dat", ios: : in|ios: : out); // f. open("x. dat", ios: : in|ios: : out); for(i=0; i> x[i]; f. close(); cout << "Массив X" << endl; for(i=0; i