int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int xmax, ymax; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, "C:\\Turboc3\\BGI"); /* read result of initialization */ errorcode = graphresult(); /* an error occurred */ if (errorcode != grOk) { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); } setcolor(getmaxcolor()); //xmax = getmaxx(); // ymax = getmaxy(); line(50,50,100,50); line(100,50,100,100); line(100,100,50,100); line(50,50,50,100); //printf("%d",getpixel(70,70)); boundaryFill(70,70,getmaxcolor()); getch(); closegraph(); return 0; }

void main() { int driver=DETECT,mode; int X1=250,Y1=244,R1=50, X2=260,Y2=233,R2=70, X3=270,Y3=210,R3=100; registerbgidriver(EGAVGA_driver); initgraph(&driver,&mode,""); setcolor(DARKGRAY); circle(X3,Y3,R3); setfillstyle(1,DARKGRAY); floodfill(X3,Y3,DARKGRAY); delay(30); setcolor(LIGHTGRAY); circle(X2,Y2,R2); setfillstyle(1,LIGHTGRAY); floodfill(X2,Y2,LIGHTGRAY); delay(30); setcolor(WHITE); circle(X1,Y1,R1); setfillstyle(1,WHITE); floodfill(X1,Y1,WHITE); delay(30); getch(); setcolor(11); outtextxy(10,450,"*-*-*-*-*-*-*-*-*-*-*-*-*" " ISN'T IT A BEAUTIFUL BALL?" " *-*-*-*-*-*-*-*-*-*-*-*-*-*"); getch(); closegraph(); }

int gettoken(void) { int c, getch(void); void ungetch(int); if(pretoken) { pretoken = 0; return tokentype; } char *p = token; while((c = getch()) == ' ' || c == '\t'); if(c == '(') { if((c = getch()) == ')'){ strcpy(token,"()"); return tokentype = PARENS; } else { ungetch(c); return tokentype = '('; } } else if (c == '[') { for(*p++ = c;(*p++ = getch()) != ']';); *p = '\0'; return tokentype = BRACKETS; } else if(isalpha(c)) { for(*p++ = c; isalnum(c = getch());) *p++ = c; *p = '\0'; ungetch(c); return tokentype = NAME; } else return tokentype = c; }

int main() { WINDOW *p; initscr(); /* create a new pad */ p = newpad(50,100); if( p == NULL ) { addstr("Unable to create new pad"); refresh(); endwin(); return(1); } addstr("New pad created"); refresh(); getch(); if( delwin(p)==OK) addstr("...and now it's gone!\n"); else addstr("...and it's still there!\n"); refresh(); getch(); endwin(); return 0; }

int main() { int count = 1, gDriver = DETECT, gMode; initgraph(&gDriver, &gMode, "C\\:tc\\bgi"); i.x.ax = 0; int86(0X33, &i, &o); if (o.x.ax == 0) { printf("ntMouse Support is Unavailable !!"); } else { showmouseptr(); while (count <= 10) { getch(); count++; if (count % 2 == 0) hidemouseptr(); else showmouseptr(); } } getch(); return 0; }

int getop(char s[]) { int i, c; while((s[0] = c = getch()) == ' ' || c == '\t') ; s[1] = '\0'; if(!isdigit(c) && c != '.') { return c; } i = 0; if(isdigit(c)) { while(isdigit(s[++i] = c = getch())) ; } if(c == '.') { while(isdigit(s[++i] = c = getch())) ; } s[i] = '\0'; if(c != EOF) { ungetch(c); } return NUMBER; }

/* get next integer from input into *pn */ int getint(int *pn) { int c, sign; while (isspace(c = getch())) ; if (!isdigit(c) && c != EOF && c != '+' && c != '-') { ungetch(c); return 0; } sign = c == '-' ? -1 : 1; if (c == '+' || c == '-') { c = getch(); if (!isdigit(c)) { ungetch(sign == 1 ? '+' : '-'); return 0; } } for (*pn = 0; isdigit(c); c = getch()) *pn = 10 * *pn + c - '0'; *pn *= sign; if (c != EOF) ungetch(c); return c; }

/********************** Wicket Fallen ************************/ void myscore::wicket(void) { int o_type,new_player; cout<<"\n\n*********************************\n"; cout<<" Wicket\n"; cout<<"*********************************\n"; cout<<"\nOut type? (Bold-1:Caught-2:Run_out:3)......."; cin>>o_type; Out++; Ball_count++; team1.Set_Ball(player1); if(Out>=Max_out){cout<<"\n\n*********************************\n"; cout<<" Innings Complete\n"; cout<<"*********************************\n"; team1.Set_Status(player1,o_type+1); getch(); return; } cout<<"\nNew Batsmans no: "; cin>>new_player; team1.Set_Out(player1,o_type+1,new_player); player1=new_player; if(Ball_count==6){over_complete();return;} getch(); show(); }

int main(void) { char ch; int n, i; printf("你要執行程式嗎? 按Y執行，其他 任意鍵 離開：\n"); ch = getch(); if (((ch == 'y') || (ch == 'Y'))) { ch = 'q'; while (((ch != 'y') || (ch != 'Y'))) { int n, sum = 0; printf("請輸入N值: "); scanf("%d", &n); for (i = 1; i <= n; i++) { sum += i; } printf("由1累加到 %d 是 %d \n", n, sum); printf("要再次執行嗎? 按 任意鍵 繼續, 按 N 或 n 離開：\n"); ch = getch(); if (((ch == 'n') || (ch == 'N'))) { return 0; } } } else { return 0; } }

static int sudoku_get(const char *filename) { int fd; int i, j; char buf[10]; fd = open(filename, O_RDONLY); if (fd == -1) { printf("open %s error!\n", filename); getch(); exit(-1); } for (i = 0; i < 9; i++) { read(fd, buf, 10); for (j = 0; j < 9; j++) { if ((buf[j] >= '0') && (buf[j] <= '9')) { sudoku[i][j].data = buf[j] - '0'; sudoku[i][j].flag = FLAG_SET(buf[j] - '0'); } else { printf("ERROR - Please check origin data\n"); getch(); exit(-1); } } } if (fd) close(fd); return 0; }

int getfloat(float *pn) { int c,sign; float power; while(isspace(c=getch())) ; if(!isdigit(c)&&c!=EOF&&c!='+'&&c!='-'&&c!='.') { ungetch(c); return 0; } sign=(c=='-')?-1:1; if(c=='+'||c=='-') c=getch(); for(*pn=0.0; isdigit(c); c=getch()) *pn=10.0* *pn + (c-'0'); if(c=='.') c=getch(); for(power=1.0; isdigit(c); c=getch()) { *pn=10.0 **pn+(c-'0'); power==10.0; } *pn==sign/power; if(c!= EOF) ungetch(c); return c; }

int getint(int *pn) { int c,sign; while(isspace(c=getch())) ; if(!isdigit(c) && c !=EOF && c!='+' && c!='-') { ungetch(c); /* it's not a number */ return 0; } sign = (c == '-') ? -1 : 1; if(c=='+' || c=='-') c = getch(); for(*pn = 0; isdigit(c);c=getch()) *pn = 10 * *pn + (c-'0'); *pn *= sign; if(c!=EOF) ungetch(c); return c; }

//---------------------------------------------------------- // isActive används när man vill skriva till TextFältet //---------------------------------------------------------- void TextField::isActive() { bool stop = false; while(!stop) { gotoxy(getLeft(), getTop()); this->draw(); char key=getch(); /*Special*/ if(key==0) { char key=getch(); switch(key) { /*Pil VÄNSTER*/ case CHLEFT: TextObjekt::left(); break; /*Pil HÖGER*/ case CHRIGHT: TextObjekt::right(); break; /*Del*/ case CHDEL: TextObjekt::del(); break; /*ANNAN*/ default: break; } } switch(key) { /*Baksteg*/ case 8: this->baksteg(); break; /*TAB <-->*/ case 9: for(int i=0; i<4; ++i) { this->putIn(' '); } break; /*Esc*/ case CHESC: stop = true; break; /*Enter*/ case ENTER: stop = true; break; /*Tecken a-z*/ default: this->putIn(key); break; } } }

int getint(int *iptr) { int ch, sign = 1; while ((ch = getch()) == ' ' || ch == '\t') //Skip whitespace ; if (!isdigit(ch)) { if (ch == '-') { sign = -1; } else if (ch == '+') { sign = 1; } else if (ch != EOF) { return 0; //Not a number } else { return EOF; } } else { ungetch(); } if (!isdigit(ch = getch())) { //Lone sign check return 0; //Not a number } else { ungetch(); } *iptr = 0; while (isdigit(ch = getch())) { *iptr = (*iptr * 10) + (ch - '0'); } *iptr *= sign; return 1; //Number written on *iptr }

/* support negation number, number with sign operator, must come without tab or space*/ int getop2(char s[]) { int i, c1, c2; // can't be '\n' while ((s[0] = c1 = getch()) == ' ' || c1 == '\t'); s[1] = '\0'; if (c1 == '+' || c1 == '-') { c2 = getch(); if (!isdigit(c2) && c2 != '.') { // '+' or '-' as operator ungetch(c2); return c1; } i = 0; s[++i] = c1 = c2; } else if (!isdigit(c1) && c1 != '.') return c1; // not a number else i = 0; if (isdigit(c1)) while (isdigit(s[++i] = c1 = getch())); // integer part if (c1 == '.') while (isdigit(s[++i] = c1 = getch())); // fraction part s[i] = '\0'; if (c1 != EOF) ungetch(c1); return NUMBER; }

/* * Write a function htoi(s), which converts a string of hexadecimal digits * (including an optional 0x or 0X) into its equivalent integer value. The * allowable digits are 0 through 9, a through f, and A through F. */ int main() { char hex[MAX_LEN]; printf("\nHexadecimal number(Max 8 digits) : "); scanf("%s", hex); putchar('\n'); if (hex[0] == '0' && (hex[1] == 'x' || hex[1] == 'X')) { if (strlen(hex) > ((sizeof(long) * 2) + 2)) { printf("Enter a maximum of 8 digits only\n"); getch(); return 1; } } else if (strlen(hex) > sizeof(long) * 2 ) { printf("Enter a maximum of 8 digits only\n"); getch(); return 1; } printf("Decimal equivalent : %d\n", htoi(hex)); getch(); return 0; }

/* Description: get next character or numberic operand * Version: 1.0 * Date: 2014.06.04 * Author: Jasper Li */ int getop( char s[]) { char c; int i; //skip while space while((c=getch()) == ' ' || c == '\t' ) ; s[0] = c; s[1] = '\0'; if( !isdigit(c) && c != '.') return c; // not a number i=0; if(isdigit(c)) // collect integer part while(isdigit(s[++i] = c = getch())) ; if(c=='.') //colect fraction part while(isdigit(s[++i] = c = getch())) ; //at this time s[i] is not a digit s[i] = '\0'; if(c != EOF) ungetch(c); return TYPE_NUMBER; }

void main() { int j=0,num=0,mul=0; char ch; clrscr(); printf("\n\tHello! Amit , How are you today?"); printf("\nNow Let us learn!!!!"); getch(); do { clrscr(); printf("\n\t\t\t****MULTIPLICATION TABLES****"); printf("\n\tEnter the Number whose table you want to print:"); scanf("%d",&num); printf("\tMultiplication Table of :: %d",num); for(j=1;j<=30;j++) { mul = num*j; printf("\n"); printf("%d X %d= %d",num,j,mul); getch(); if(j%10==0) { clrscr(); } } printf("\n\t Enter (N) for NEXT table OR press any key to exit!!!:\t"); ch=getch(); }while(ch=='n'|| ch=='N'); printf("\n\t\t\t\Exiting ....."); getch(); }

int getop(char s[]) { int i,c; while ((s[0] = c = getch()) == ' ' || c == '\t') ; s[1] = '\0'; if (!isdigit(c) && c != '.' && c != '-') return c; if (c == '-') if (isdigit(s[i++] = c = getch()) || c == '.') s[i++] = c; else { if (c != EOF) ungetch(c); return '-'; } if (isdigit(c)) while (isdigit(s[i++] = c = getch())) ; if (c == '.') while (isdigit(s[i++] = c = getch())) ; s[i] = '\0'; if (c != EOF) ungetch(c); return NUMBER; }

//Cria o menu inicial menu1 (){ system ("cls"); cabecalho(); printf ("OPÇÕES\n\n1 - Novo jogo. \n2 - Instruções.\n3 - Sair.\n\n\n---> "); validaopcao (); switch (opcao){ case 1: system ("cls"); cabecalho(); informa (); break; case 2: system ("cls"); cabecalho(); printf ("\t\t\t INSTRUÇÕES\n\n"); printf ("1 - Informe os nomes dos jogadores. \n2 - As jogadas são alternadas. \n3 - Ganha o jogador que marcar três posições em sequencia.\n"); getch (); menu1(); break; case 3: system("CLS"); printf("\n\n *********************************************************\n"); printf(" * *\n"); printf(" * Obrigado por jogar TicTacToe. *\n * Desenvolvido por José Tarciso e Olliver Felipe. *\n * *\n * Pressione qualquer tecla para sair... *\n * *\n *********************************************************"); printf("\a\a\a"); getch(); printf("\a\a"); exit (EXIT_SUCCESS); break; } }

void main() { int src,i,j; clrscr(); cout<<"\n enter the no of vertices\n"; cin>>n; cout<<"\nenter adjacency matrix\n"; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) cin>>a[i][j]; vis[i]=0; } cout<<"\nenter the source\n"; cin>>src; cout<<"\n nodes reachable frm source"<<src<<" are \n"; for(i=src;i<=n;i++) { src=i; for(j=1;j<=n;j++) vis[j]=0; dfs(src); for(j=1;j<=n;j++) { if (vis[j]==0) { cout<<"\nthe graph is not connected\n"; getch(); exit(0); } } } cout<<"\nthe given graph is connected\n"; getch(); }

/*Вычислить корни квадратного уравнения ax^2 + bx + c = 0 зажанного коэфициентами a, b, c (a <> 0 и дискриминант => 0)*/ void main() { clrscr(); float a, b, c, d, x1, x2; printf("введите коэфициенты a b c: "); scanf("%f %f %f", &a, &b, &c); d = (b * b) - (4 * a * c); if(a == 0) { printf("\nа недолжно равняться 0"); getch(); return; } if(d < 0) { printf("\nДискриминант отрицательный "); getch(); return; } x1 = (-b - sqrt(d)) / (2 * a); x2 = (-b + sqrt(d)) / (2 * a); printf("\nКорни уравнения (%.2f;%.2f)", x1, x2); getch(); }

void test4(void) { int y, x, row, col; int prev = EOF; int ch; FILE *fp = openFile("hello.c", "r"); getmaxyx(stdscr, row, col); while ((ch = fgetc(fp)) != EOF) { getyx(stdscr, y, x); if (y == (row - 1)) { printw("<-Press Any Key->"); getch(); clear(); move(0, 0); } if (prev == '/' && ch == '*') { attron(A_BOLD); getyx(stdscr, y, x); move(y, x - 1); printw("%c%c", '/', ch); } else { printw("%c", ch); } refresh(); if (prev == '*' && ch == '/') { attroff(A_BOLD); } prev = ch; } getch(); closeFile(fp); }

/* getop: get next operator or numeric operand */ int getop(char s[]){ int c, i; while ((s[0] = c = getch()) == ' ' || c == '\t') ; s[1] = '\0'; i = 0; if (!isdigit(c) && c != '.' && c != '-') return c; /* not a number */ if (c == '-') if (isdigit(c = getch()) || c == '.') s[++i] = c; /* negative number */ else { if ( != EOF) ungetch(c); return '-'; /* minus sign */ } if (isdigit(c)) /* collect integer part */ while (isdigit(s[++i] = c = getch())) ; if (c == '.') /* collect fraction part */ while (isdigit(s[++i] = c = getch())) ; s[i] = '\0'; if (c != EOF) ungetch(c); return NUMBER; }

/* getint: get next integer from input into *pn */ int getint(int *pn) { int c, sign; while (isspace(c = getch())) /* skip white space */ ; if (!isdigit(c) && c != EOF && c != '+' && c != '-') { ungetch(c); /* it's not a number */ return 0; } sign = (c == '-') ? -1 : 1; if (c == '+' || c == '-') { c = getch(); if (!isdigit(c)) { /* + or - not followed by a digit */ ungetch(c); /* ungetch non-digit */ ungetch(sign == 1 ? '+' : '-'); /* ungetch + or - */ return 0; } } for (*pn = 0; isdigit(c); c = getch()) *pn = 10 * *pn + (c - '0'); *pn *= sign; if (c != EOF) ungetch(c); return c; }

/* * getop: Gets the next operator or operand from the input. Returns code NUMBER ('0') if * a number was found, or the next character if not (including the EOF character). Can * get negative numbers. */ int getop(char s[]) { int i = 0; while ((s[i] = getch()) == ' ' || s[i] == '\t'); if (!isdigit(s[i]) && s[i] != '.') { // Is either an operator, a sign, or nothing useful if (s[i] == '-' || s[i] == '+') { s[++i] = getch(); if (isspace(s[i])) { ungetch(s[i]); // The '-' or '+' was just an operator after all return s[--i]; } } else return s[i]; // definitely not a number } // Is a number if (isdigit(s[i])) while (isdigit(s[++i] = getch())); if (s[i] == '.') while (isdigit(s[++i] = getch())); if (s[i] != EOF) ungetch(s[i]); s[i] = '\0'; return NUMBER; }

void main() { long double num,temp,hit1; int x=70; char hit; clrscr(); hit=getch(); hit1=hit*1.0; temp=hit1-48.0; //printf("%",hit1); num=temp; gotoxy(x,5); printf("%12.2Lf",num); while((hit=getch())!='x') { clrscr(); hit1=hit*1.0; temp=hit1*1.0-48.0; num=num*10.0+temp; //x--; gotoxy(x,5); printf("%12.2Lf",num); } }

int main(int argc, char *argv[]) { struct winsize Size; if(isatty(STDIN_FILENO)==0) exit(NO_FD_WITH_TERM); if(ioctl(STDIN_FILENO,TIOCGWINSZ,&Size)<0) exit(GET_WINDOW_SIZE_ERROR); //The size should be fixed.or it's hard to control ROWS=Size.ws_row; COLUMNS=Size.ws_col; N=sizeof(char)*(ROWS+1)*(COLUMNS+1); ScreenTable=(char*)malloc(N); memset(ScreenTable,0,N); Move=(char*)malloc(N); memset(Move,0,N); initscr(); //welcome information and select level move(ROWS/2,COLUMNS/2-12); printw("%s","Please Select a Level(1-6):"); LEVEL=getch(); refresh(); sleep(1); if((LEVEL<49)||(LEVEL>54)) LEVEL=49; clear(); refresh(); move(ROWS/2,COLUMNS/2-5); printw("%s","Ready?Go!"); refresh(); sleep(1); clear(); refresh(); //create a thread to receive keyboard input int res; pthread_t keyb; res=pthread_create(&keyb,NULL,animation,NULL); if(res!=0) { perror("Thread Creation failed"); save_exit(THREAD_CREATE_FAILED); } cbreak(); noecho(); while(1) { TYPINGCHAR=getch(); while(TYPINGCHAR=='\n') break; isOld=0; } save_exit(EXIT_SUCCESS); }

long input(long ch) { if (ch == -1) { ch = getch(); } // Our current tiles and Windows code doesn't have ungetch() #if !(defined TILES || defined SDLTILES || defined _WIN32 || defined WINDOWS) int newch; // Clear the buffer of characters that match the one we're going to act on. timeout(0); do { newch = getch(); } while( newch != ERR && newch == ch ); timeout(-1); // If we read a different character than the one we're going to act on, re-queue it. if (newch != ERR && newch != ch) { ungetch(newch); } #endif switch (ch) { case KEY_UP: return 'k'; case KEY_LEFT: return 'h'; case KEY_RIGHT: return 'l'; case KEY_DOWN: return 'j'; case KEY_NPAGE: return '>'; case KEY_PPAGE: return '<'; case 459: return '\n'; default: return ch; } }

int main() { int ch; initscr(); /* Start curses mode */ raw(); /* Line buffering disabled */ noecho(); /* Stop printing junk, bro! */ keypad(stdscr, TRUE); /* We get to press ALL the keys!! */ printw("Type any character to see it nice 'n' thick...\n"); ch = getch(); if (ch == KEY_F(2)) printw("F2 Key was pressed, dawg."); else { printw("You pressed: "); attron(A_BOLD); printw("%c", ch); attroff(A_BOLD); } // Display, wait, and end: refresh(); /* Print it on to the real screen */ getch(); /* Wait for user input */ endwin(); /* End curses mode */ return 0; }