⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 travel14.c

📁 This is code tutorial for image processing include:histogram,sketon....
💻 C
📖 第 1 页 / 共 5 页
字号:
             printf("\nEnter the data file name:");             printf("______________________________");             for(i=0; i<30; i++) printf("\b");             gets(data_file_name);             data_file = fopen(data_file_name, "r");             if(data_file == '\0'){                printf("\nERROR: Could not open data file %s",                          data_file_name);                exit(-1);             }  /* ends opening data file */             fread(name, (L*sizeof(char)), 1, data_file);             fread(ORN,  (L*sizeof(char)), 1, data_file);             fread(&cash_advance, sizeof(long), 1, data_file);             GTR   = retrieve_GTRs(data_file);             ts    = retrieve_transportation_cost(data_file);             its   = retrieve_itinerarys(data_file);             ds    = retrieve_daily_expenses(data_file, &days);             rs    = retrieve_rental_expenses(data_file);             fclose(data_file);             printf("\nDo you want to edit ");             printf("this accounting? (y or n)");             gets(r);             if(r[0] == 'y' || r[0] == 'Y'){                review_accounting(name, ORN, &cash_advance,                                  GTR, ts, its, ds, rs);             }  /* ends edit accounting */             printf("\nDo you want to print? (y or n)");             gets(print);             if(print[0] == 'y' || print[0] == 'Y'){                tmpnam(print_file_name);                print_file = fopen(print_file_name, "wt");                if(print_file == '\0'){                   printf("\nERROR Could not open print file %s",                           print_file_name);                   exit(2);                }  /* ends if could not open print file */                get_first_last_dates(its, &first_day, &last_day);                print_accounting(date_string, name, ORN,                                  days, &lines, print_file,                                 &first_day, &last_day,                                 cash_advance, GTR, ts,                                 its, ds, rs);                lines = 0;                fclose(print_file);                if(UNIX_SYSTEM){                   printf("\nEnter the name of the printer:");                   printf(" (e.g. GE02_SPARC, ps1, ps, etc.)");                   printf("\n     __________\b\b\b\b\b\b\b\b\b\b");                   gets(printer_name);                   sprintf(r, "lpr -P%s %s",                       printer_name, print_file_name);                }                if(DOS_SYSTEM)                   sprintf(r, "type %s > prn", print_file_name);                system(r);                unlink(print_file_name);             }  /* ends if yes print */             printf("\nDo you want to save ");             printf("this edited accounting? (y or n)");             gets(r);             if(r[0] == 'y' || r[0] == 'Y'){                 get_data_file_name(name, date_string, data_file_name);                data_file = fopen(data_file_name, "w");                if(data_file == '\0'){                   printf("\nERROR: Could not create data file %s",                             data_file_name);                   exit(-1);                }  /* ends opening data file */                   /* save the data to the data file */                fwrite(name, (L*sizeof(char)), 1, data_file);                fwrite(ORN,  (L*sizeof(char)), 1, data_file);                fwrite(&cash_advance, sizeof(long), 1, data_file);                save_GTRs(GTR, data_file);                save_transportation_cost(ts, data_file);                save_itinerarys(its, data_file);                save_daily_expenses(ds, data_file);                fclose(data_file);                printf("\n\nWrote your data to file: %s",                       data_file_name);             }  /* ends if save edited accounting */             break;          default:             printf("\n\nSorry, cannot understand your ");             printf("choice, try again.");             break;       }  /* ends switch choice */   }  /* ends while not_finished */      /* free up the memory you allocated */   free(GTR);   free(ts);   free(its);   free(ds);}  /* ends main *//*****************************************************//*****************************************************//*****************************************************//*PAGE review_accounting   This function is the main routine for the   review process.  It shows menus, interprets   the responses and calls other functions to make   changes as desired.*/review_accounting(name, ORN, cash_advance,                  GTR, ts, its, ds, rs)   char    name[], ORN[];   long    *cash_advance;   struct  daily_struct      *ds;   struct  GTR_struct       *GTR;   struct  itinerary_struct *its;   struct  trans_struct     *ts;   struct  rental_struct    *rs; {   char r[L];   int  choice, not_finished = 1;   while(not_finished){      show_review_menu();      gets(r);      choice = atoi(r);      switch(choice){         case 0:            not_finished = 0;            break;         case 1: /* name and ORN */            edit_name_orn(name, ORN);            break;         case 2: /* cash advance */            edit_cash_advance(cash_advance);             break;         case 3: /* GTR */            edit_GTRs(GTR);            break;         case 4: /* Transportation cost */            edit_trans_cost(ts);            break;         case 5: /* Itenerary */            edit_itinerary(its);            break;         case 6: /* Daily Expenses */            edit_daily_expenses(ds);            break;         case 7: /* Rental Car Use */            edit_rental_expenses(rs);            break;         default:            printf("\n\nSorry, cannot understand your");            printf(" choice, try again.");            break;      }  /* ends switch choice */   }  /* ends while not_finished */}  /* ends review_accounting *//*****************************************************//*****************************************************//*PAGE edit_name_orn   This function allows the user to edit the   traveller's name and ORN.*/edit_name_orn(name, ORN)   char name[], ORN[];{   char r[L];   int  choice, not_finished = 1;   while(not_finished){      printf("\n");      printf("\n\t1. Name is %s", name);      printf("\n\t2. ORN is %s", ORN);      printf("\n\n\tEnter number to make a change, 0 to quit");      printf("\n\t__\b\b");      gets(r);      choice = atoi(r);      switch(choice){         case 0:            not_finished = 0;            break;         case 1:            get_name(name);            break;         case 2:            get_orn(ORN);            break;         default:            printf("\n\nSorry, cannot understand your");            printf(" choice, try again.");            break;      }  /* ends switch choice */   }  /* ends not_finished */}  /* ends edit_name_ORN *//*****************************************************//*****************************************************//*PAGE edit_cash_advance   This function allows the user to edit the   cash advance.*/edit_cash_advance(cash_advance)   long *cash_advance;{   char r[L];   int  choice, not_finished = 1;   long temp;   temp = *cash_advance;   while(not_finished){      printf("\n");      printf("\n\t1. Cash advance is $%8.2f", dollars_of(temp));      printf("\n\n\tEnter number to make a change, 0 to quit");      printf("\n\t__\b\b");      gets(r);      choice = atoi(r);      switch(choice){         case 0:            not_finished = 0;            break;         case 1:            printf("\n\tCash Advance Amount? ");            temp = get_money();            break;         default:            printf("\n\nSorry, cannot understand your");            printf(" choice, try again.");            break;      }  /* ends switch choice */   }  /* ends while not_finished */   *cash_advance = temp;}  /* ends edit_cash_advance *//*****************************************************//*****************************************************//*PAGE edit_GTRs   This function allows the user to edit the   GTRs.*/edit_GTRs(GTR)   struct GTR_struct *GTR;{   char   r[L];   int    choice, not_finished = 1;   long   temp;   struct GTR_struct *g;   g = GTR;   while(not_finished){      printf("\n");      printf("\n\t1. GTR is $%8.2f",              dollars_of(g->GTR));      printf("\n\n\tEnter 1 to change this GTR");      printf("\n\tEnter 2 to go on to next GTR");      printf("\n\t__\b\b");      gets(r);      choice = atoi(r);      if(choice == 1){         printf("\nEnter new GTR:________\b\b\b\b\b\b\b\b");         temp   = get_money();         g->GTR = temp;      }  /* ends if choice == 1 */      if(choice == 2){         if(g->next == END_OF_LIST){            printf("\nNo more advances to edit");            not_finished = 0;         }  /* ends if END_OF_LIST */         else            g = g->next;      }  /* ends if choice == 2 */   }  /* ends while not_finished */}  /* ends edit_GTRs *//*****************************************************//*****************************************************//*PAGE edit_trans_cost   This function allows the user to edit the   transportation costs.*/edit_trans_cost(ts)   struct trans_struct *ts;{   char   r[L];   int    choice, j, not_finished = 1;   struct trans_struct *t;   t = ts;   while(not_finished){      printf("\n");      printf("\n\t1. Mode: %s", t->mode);      printf("\n\t2. Carrier: %s", t->carrier);      printf("\n\t3. Class: %s", t->travel_class);      printf("\n\t4. Amount: $%8.2f",               dollars_of(t->amount));      printf("\n\t5. Go on to the next transportation");      printf("\n\t6. Quit editing transportation costs");      printf("\n");      printf("\n\tEnter the number to change:__\b\b");      gets(r);      choice = atoi(r);      switch(choice){         case 1:            printf("\n\tMode:______________________________");            printf("(enter 0 to quit)");            for(j=0; j<47; j++) printf("\b");            gets(t->mode);            break;         case 2:            printf("\n\tCarrier:______________________________");            for(j=0; j<30; j++) printf("\b");            gets(t->carrier);            break;         case 3:            printf("\n\tTravel Class:______________________________");            for(j=0; j<30; j++) printf("\b");            gets(t->travel_class);            break;         case 4:            printf("\n\tAmount:");            t->amount = get_money();            break;         case 5:            if(t->next == END_OF_LIST){               printf("\n\nNo more to edit");               not_finished = 0;            }  /* ends if END_OF_LIST */            else               t = t->next;            break;         case 6:            not_finished = 0;            break;         default:            printf("\n\nSorry, cannot understand your");            printf(" choice, try again.");            break;      }  /* ends switch choice */   }  /* ends while not_finished */}  /* ends edit_trans_cost *//*****************************************************//*****************************************************//*PAGE edit_itinerary   This function allows the user to edit the   itinerary.*/edit_itinerary(its)   struct itinerary_struct *its;{   char   r[L], s[L];   int    choice, i, not_finished = 1;   struct itinerary_struct *t;   struct MDY_struct       dummy;   t = its;   while(not_finished){      printf("\n");      printf("\n\t1. Departure: %2d-%2d-%2d",              t->depart_date.month,              t->depart_date.day,              t->depart_date.year);      printf("\n\t2. Leaving: %s", t->leave_loc);      printf("\n\t3. Time: %ld", t->depart_time);      printf("\n\t4. Via: %s", t->depart_via);      printf("\n\t5. Arrival: %2d-%2d-%2d",              t->arrive_date.month,              t->arrive_date.day,              t->arrive_date.year);      printf("\n\t6. Arriving: %s", t->arrive_loc);      printf("\n\t7. Time: %ld", t->arrive_time);      printf("\n\t8. Go on to the next itinerary.");      printf("\n\t9. Quit editing itinerary");      printf("\n");      printf("\n\tEnter the number to change:__\b\b");      gets(r);      choice = atoi(r);      switch(choice){         case 1:            printf("\nEnter the new departure date");            get_mdy(&dummy);            t->depart_date.month = dummy.month;            t->depart_date.day   = dummy.day  ;            t->depart_date.year  = dummy.year ;            break;         case 2:            printf("\nLeaving:______________________________");            for(i=0; i<30; i++) printf("\b");            gets(t->leave_loc);            break;         case 3:            printf("\nAt:____ (24 hour time - no colon)");            for(i=0; i<30; i++) printf("\b");            gets(s);            t->depart_time = atoi(s);            break;         case 4:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -