int days(int year, int month ,int day) { int error = 0; int caculate(int year, int month, int day); void leap(int year); leap(date.year); do { if(date.month < 1 || date.month > 12 || monthday[date.month] < 1 || monthday[date.month] < date.day) { error = 1; printf("请重新输入月份和日期:\n"); scanf("%d,%d", &date.month,&date.day); } else error =0; }while(error == 1); printf("%d年%d月%d日是该年份中的第%d天。\n", date.year, date.month, date.day, caculate(date.year, date.month, date.day)); return 0; }
int a3_write(FILE * fp_spl,FILE * fp_in ,FILE * fp_out) { int count; memset(buf,0,sizeof(buf)); count = fread(buf,sizeof(buf[0]),sizeof(buf)/sizeof(buf[0]),fp_spl); caculate(); fwrite(buf,sizeof(buf[0]),sizeof(buf)/sizeof(buf[0]),fp_out); while(!feof(fp_spl)) { count=fread(buf,sizeof(buf[0]),sizeof(buf)/sizeof(buf[0]),fp_spl); fwrite(buf,sizeof(buf[0]),count,fp_out); } while(!feof(fp_in)) { count=fread(buf,sizeof(buf[0]),sizeof(buf)/sizeof(buf[0]),fp_in); fwrite(buf,sizeof(buf[0]),count,fp_out); } return 0; }
int main() { while (scanf("%d %d", &n, &c)==2&&n) { for (int i=1; i<=n; i++) for (int j=1; j<=i; j++) scanf("%d", &map[i][j]); int ret=-inf; for (int i=1; i<=n; i++) for (int j=1; j<=i; j++) if (map[i][j]==0) { map[i][j]=c; int tmp=caculate(c); map[i][j]=0; if (tmp>ret) ret=tmp; } printf("%d\n", ret); } return 0 ; }
main() { char infix[100]; char postfix[100]; int choice,quit = 0; while(quit == 0) { choice = menu(); switch(choice) { case 1: printf("\nEnter infix: "); scanf("%s",infix); rmenu(); break; case 2: inFix_to_postFix(infix,postfix); printf("\nPostfix: %s\n",postfix); rmenu(); break; case 3: printf("\nResult: %.1f\n",caculate(postfix)); rmenu(); break; case 4: about(); rmenu(); break; case 5: printf("Have funny time!!\n"); quit++; break; default: printf("Please choose from 1 to 5.\n"); } } return 0; }
static int button_handle (struct ts_button *button, struct ts_sample *samp) { int inside = (samp->x >= button->x) && (samp->y >= button->y) && (samp->x < button->x + button->w) && (samp->y < button->y + button->h); if (samp->pressure > 0) { if (inside) { if (!(button->flags & BUTTON_ACTIVE)) { button->flags |= BUTTON_ACTIVE; button_draw (button); /*Calculator Process*/ if(button->text[0] == 'C'){ // Clear opVal = 0; value = 0; isCaculate = 0; } else if(button->text[0] == "D"){ // DELete opVal = 0; value /= 10; isCaculate = 0; } else if(button->text[0] == '+'){ if(opSort) caculate(opSort); opVal = value; value = 0; opSort = 1; isCaculate = 0; } else if(button->text[0] == '-'){ if(opSort) caculate(opSort); opVal = value; value = 0; opSort = 2; isCaculate = 0; } else if(button->text[0] == '*'){ if(opSort) caculate(opSort); opVal = value; value = 0; opSort = 3; isCaculate = 0; } else if(button->text[0] == '/'){ if(opSort) caculate(opSort); opVal = value; value = 0; opSort = 4; isCaculate = 0; } else if(button->text[0] == '='){ switch(opSort){ case 1: opVal += value; break; case 2: opVal -= value; break; case 3: opVal *= value; break; case 4: opVal /= value; break; } value = opVal; isCaculate = 1; opSort = 0; } else{ //number if(isCaculate){ isCaculate = 0; value = 0; } value = 10*value + button->text[0] - '0';//char->int } refresh_screen(); char str_value[50];//int -> char for display sprintf(str_value,"%lf",value); put_string_center(xres/2,7*yres/50,str_value,1); } } else if (button->flags & BUTTON_ACTIVE) { button->flags &= ~BUTTON_ACTIVE; button_draw (button); } } else if (button->flags & BUTTON_ACTIVE) { button->flags &= ~BUTTON_ACTIVE; button_draw (button); return 1; } return 0; }