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

📄 travel14.c

📁 This is code tutorial for image processing include:histogram,sketon....
💻 C
📖 第 1 页 / 共 5 页
字号:
            looking = 0;         else{            fclose(fp);            printf("\nFile %s already exists", s2);            printf("\nTry another file name");         }  /* ends else tried another name */      }  /* ends while looking */      strcpy(file_name, s2);   }  /* ends if DOS_SYSTEM */}  /* ends get_data_file_name *//*****************************************************//*****************************************************//*PAGE get_orn   Interact with the user to get the    ORN.*/get_orn(a)   char a[];{   int i;   printf("\n\t\tORN:______________________________");   for(i=0; i<30; i++) printf("\b");   gets(a);}  /* ends get_orn *//*****************************************************//*****************************************************//*PAGE get_money   This function interacts with the user   to get a money value.  It gets it as   a float and returns it to the caller   as a long.*/long get_money(){   char  r[L];   float f;   long  l;   gets(r);   f = atof(r);   f = f + 0.005;   l = pennies_of(f);   return(l);}  /* ends get_money *//*****************************************************//*****************************************************//*PAGE get_number   This functions prompts the user with   the string given in the input, reads    an integer from the keyboard, and    returns that integer to the calling   function.*/get_number(s)   char s[];{   char r[80];   int  result;   printf("\n\t%s: ", s);   gets(r);   result = atoi(r);   return(result);}  /* ends get_number *//*****************************************************//*****************************************************//*PAGE get_transportation_cost   This function gets the   transportation cost structures.*/struct trans_struct * get_transportation_cost(){   char s[L];   int first=1, j, not_done=1;   struct trans_struct *current, *new1, *result;   while(not_done){      printf("\n\tMode:______________________________");      printf("(enter 0 to quit)");      for(j=0; j<47; j++) printf("\b");      gets(s);      if(s[0] == '0'){         not_done = 0;            /* if the user enters 0 on the first try,               then create at least one instance of               the struct to pass back. */         if(first){            first = 0;            new1 = (struct trans_struct *)                     calloc(1, sizeof(struct trans_struct));            new1->next = END_OF_LIST;            result     = new1;            strcpy(result->mode, s);         }  /* ends if first */       }  /* ends if s[0] == '0' */      else{  /* get data */         new1 = (struct trans_struct *)                  calloc(1, sizeof(struct trans_struct));         new1->next = END_OF_LIST;         if(first){            result   = new1;            current  = new1;            first    = 0;         }         else{            current->next = new1;            current       = new1;         }         strcpy(current->mode, s);         printf("\n\tCarrier:______________________________");         for(j=0; j<30; j++) printf("\b");         gets(current->carrier);         printf("\n\tTravel Class:______________________________");         for(j=0; j<30; j++) printf("\b");         gets(current->travel_class);         printf("\n\tAmount:");         current->amount = get_money();      }  /* ends else get data */   }  /* ends while not_done */      return(result);}  /* ends get_transportation_cost *//*****************************************************//*****************************************************//*PAGE get_GTRs   This function gets the GTR   advances.*/struct GTR_struct * get_GTRs(){   int  first=1, not_done=1;   long a;   struct GTR_struct *current, *new1, *result;   while(not_done){      printf("\nGTR or Ticket Advance Amount:");      a = get_money();      if(a == 0){         not_done = 0;            /* if the user enters 0 on the first try,               then create at least one instance of               the struct to pass back. */         if(first){            first = 0;            new1 = (struct GTR_struct *)                     calloc(1, sizeof(struct GTR_struct));            new1->next = END_OF_LIST;            new1->GTR  = 0;            result     = new1;         }  /* ends if first == 1 */      }  /* ends if a == 0 */      else{     /* get data */         new1 = (struct GTR_struct *)                  calloc(1, sizeof(struct GTR_struct));         new1->next = END_OF_LIST;         if(first){            result   = new1;            current  = new1;            first    = 0;         }         else{            current->next = new1;            current       = new1;         }         current->GTR = a;              }  /* ends else get data */   }  /* ends while not_done */   return(result);}  /* ends get_GTRs *//*****************************************************//*****************************************************//*PAGE get_itinerarys    This function gets the itinerary   for the traveler.*/struct itinerary_struct * get_itinerarys(){   char   s[L];   int    i, first=1, not_done=1;   struct MDY_struct dummy;   struct itinerary_struct *current, *new1, *result;   while(not_done){      printf("\n\t\tItinerary:");      printf("\n\t\t(enter -1 for month to quit)");      printf("\nDEPARTURE");      get_mdy(&dummy);      if(dummy.month == -1){         not_done = 0;            /* if the user enters 0 on the first try,               then create at least one instance of               the struct to pass back. */         if(first){            first = 0;            new1 = (struct itinerary_struct *)                    calloc(1, sizeof(struct itinerary_struct));            new1->next = END_OF_LIST;            result     = new1;            result->depart_date.month = -1;         }  /* ends if first */      }  /* ends if dummy.month == -1 */      else{     /* get data */         new1 = (struct itinerary_struct *)                 calloc(1, sizeof(struct itinerary_struct));         new1->next = END_OF_LIST;                       /* If first time through, then set the               result pointer to the new struct. */         if(first){            result  = new1;            current = new1;            first   = 0;         }         else{            current->next = new1;            current       = new1;         }         current->depart_date.month = dummy.month;         current->depart_date.day   = dummy.day;         current->depart_date.year  = dummy.year;         printf("\nLeaving:______________________________");         for(i=0; i<30; i++) printf("\b");         gets(current->leave_loc);         printf("\nAt:____ (24 hour time - no colon)");         for(i=0; i<30; i++) printf("\b");         gets(s);         current->depart_time = atoi(s);         printf("\nVia:______________________________");         for(i=0; i<30; i++) printf("\b");         gets(current->depart_via);         printf("\nARRIVAL");         get_mdy(&dummy);         current->arrive_date.month = dummy.month;         current->arrive_date.day   = dummy.day;         current->arrive_date.year  = dummy.year;         printf("\nArriving:______________________________");         for(i=0; i<30; i++) printf("\b");         gets(current->arrive_loc);         printf("\nAt:____ (24 hour time - no colon)");         for(i=0; i<30; i++) printf("\b");         gets(s);         current->arrive_time = atoi(s);      }  /* ends else get the data */   }  /* ends while not_done */   return(result);}  /* ends get_intenerarys *//*****************************************************//*****************************************************//*PAGE get_daily_expenses    This function runs through the   days of the trip and gets all   the expenses and descriptions.*/struct daily_struct * get_daily_expenses(first_day, last_day, days)   short  *days;   struct MDY_struct *first_day, *last_day;{   char   s[L];   int    j, looping = 1, not_done = 1;   struct daily_struct *current, *new1, *result;   struct MDY_struct dummy, next_day;   new1 = (struct daily_struct *)           calloc(1, sizeof(struct daily_struct));   new1->next = END_OF_LIST;   result     = new1;   current    = new1;   *days      = *days + 1;   current->today.month = first_day->month;   current->today.day   = first_day->day;   current->today.year  = first_day->year;   while(looping){      dummy.month = current->today.month;      dummy.day   = current->today.day;      dummy.year  = current->today.year;      printf("\nDaily Expense");      show_mdy(&dummy);      printf("\nMax Lodging at TDY Point:_____\b\b\b\b\b");      current->max_lodging = get_money();            not_done = 1;      while(not_done){         printf("\nM&IE at TDY Point:_____\b\b\b\b\b");         current->mie = get_money();                     /* change - added 3 MIE values here                        4-15-93 - DP */         if(current->mie != MIE1  &&            current->mie != MIE2  &&            current->mie != MIE3  &&            current->mie != MIE4  &&            current->mie != MIE5){            printf("\nMust equal");            show_money(MIE1);            printf(", ");            show_money(MIE2);            printf(", ");            show_money(MIE3);            printf(", ");            show_money(MIE4);            printf(", ");            show_money(MIE5);         }  /* ends if MIE values */         else            not_done = 0;      }  /* ends M&IE loop */      printf("\nActual Lodging:_____\b\b\b\b\b");      current->actual_lodging = get_money();      printf("\nPOV Miles:_____\b\b\b\b\b");      gets(s);      current->pov_miles = atoi(s);      printf("\nDesc:______________________________");      for(j=0; j<30; j++) printf("\b");      gets(current->pov_desc);      printf("\nRental Car:______\b\b\b\b\b\b");      current->rental_car = get_money();      printf("\nDesc:______________________________");      for(j=0; j<30; j++) printf("\b");      gets(current->rental_car_desc);      printf("\nTaxi:______\b\b\b\b\b\b");      current->taxi = get_money();      printf("\nDesc:______________________________");      for(j=0; j<30; j++) printf("\b");      gets(current->taxi_desc);      printf("\nParking:______\b\b\b\b\b\b");      current->parking = get_money();      printf("\nDesc:______________________________");      for(j=0; j<30; j++) printf("\b");      gets(current->parking_desc);      printf("\nOfficial Phone:______\b\b\b\b\b\b");      current->phone = get_money();      printf("\nDesc:______________________________");      for(j=0; j<30; j++) printf("\b");      gets(current->phone_desc);      printf("\nOther:______\b\b\b\b\b\b");      current->other = get_money();      printf("\nDesc:______________________________");      for(j=0; j<30; j++) printf("\b");      gets(current->other_desc);         /* now test for the end */      if(current->today.month == last_day->month   &&         current->today.day   == last_day->day     &&         current->today.year  == last_day->year)         looping = 0;      else{         new1 = (struct daily_struct *)                 calloc(1, sizeof(struct daily_struct));         new1->next    = END_OF_LIST;         current->next = new1;         current       = new1;         *days         = *days + 1;         tomorrow_is(&dummy, &next_day);         current->today.month = next_day.month;         current->today.day   = next_day.day;         current->today.year  = next_day.year;      }  /* ends else not done looping */   }  /* ends loop over the days */   return(result);}  /* ends get_daily_expenses *//*****************************************************//*****************************************************//*PAGE get_rental_expenses   This function gets the personal rental   car costs from the user.  There is only one   struct.  This is not a linked list.*/struct rental_struct * get_rental_expenses(){   char   s[L];   long   temp;   struct rental_struct *result;   result = (struct rental_struct *)             calloc(1, sizeof(struct rental_struct));   printf("\n");   printf("\nYou will be asked to sign a statement");   printf(" certifying personal");   printf("\nuse of your vehicle.  If you did not");   printf("\nhave any personal use of the vehicle,");   printf("\nanswer 0 to the following three questions.");   printf("\n");   printf("\nPersonal Mileage:________\b\b\b\b\b\b\b\b");   gets(s);   result->personal_mileage = atoi(s);   printf("\nTotal Gas:$________\b\b\b\b\b\b\b\b");   temp = get_money();   result->total_gas = temp;   printf("\nTotal Rental Car Mileage:");   printf("________\b\b\b\b\b\b\b\b");   gets(s);   result->total_mileage = atoi(s);   return(result);}  /* ends get_rental_expense */

⌨️ 快捷键说明

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