|
/*
函数数量比较多,建议用查询功能找名字。
需要可以随时复制出去,但注意函数所涉及的头文件和全局量。
有错误的话一定和俺说,但不要在这里改动。谢谢。
-晨星
*/
/***********************************************************************/
/* File : function.c */
/* */
/* History */
/* 04/21/2008 SHEN ChenXing */
/* Initial creat */
/* 04/24/2008 SHEN Chenxing */
/* Finish */
/* */
/***********************************************************************/
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define LEN sizeof(struct mission)
int Month_SumDay [12] = {31,29,31,30,31,30,31,31,30,31,30,31};
struct mission
{
char name[32];
int st_date[3];
int st_time[2];
int en_date[3];
int en_time[2];
int wdate[7];
struct mission * next;
};
/***********************************************************************/
/* Funtion : scandate */
/* Statement: input the right year,month,day . */
/* And return the process success or not. */
/* */
/* argument : */
/* int *year , int *month , int *day */
/* return : */
/* int */
/* */
/***********************************************************************/
int scandate (int *year , int *month , int *day ) /*输入日期函数,合法性判断*/
{
int k = 0 ;
do
{
if(k != 0 )
printf("\nWrong date!\n");
k ++ ;
printf ( "Please write down the day,like 1988 11 30. If you want to return enter -1.\n");
scanf ("%d" , year );
if ( *year == -1 ) return 0;
scanf ( "%d%d" , month , day );
if ( !IsLeapYear (*year) )
Month_SumDay [1] = 28 ;
} while ( *day < 1 || *day > Month_SumDay [*month-1] || *month < 1 || *month>13 || *year < 1900 || *year > 3000 );
Month_SumDay [1] = 29 ;
return 1;
}
/***********************************************************************/
/* Funtion : IsLeapYear */
/* Statement: input the right year,month,day . */
/* return it is a leap year or not. */
/* */
/* argument : */
/* int year */
/* return : */
/* int */
/* */
/***********************************************************************/
int IsLeapYear (int year) /*判断是否为闰年*/
{
if ( (year % 400 == 0 ) || ( ( year % 4 == 0 ) && ( year % 100 != 0 ) ) )
return 1;
else
return 0;
}
/***********************************************************************/
/* Funtion : scantime */
/* Statement: input the right hour, mimute and */
/* return the process success or not. */
/* */
/* argument : */
/* int *hour , int *mimute */
/* return : */
/* int */
/* */
/***********************************************************************/
int scantime ( int *hour , int *mimute )
{
int k = 0 ;
do
{
if ( k != 0 )
printf ( "\nWrong time!\n" );
k ++ ;
printf ( "Please write down the time,like 12 00. If you want to return enter -1.\n" );
scanf ( "%d" , hour );
if ( *hour == -1 ) return 0;
scanf ( "%d" , mimute );
} while ( *hour < 0 || *hour > 23 || *mimute < 0 || *mimute > 59 );
return 1;
}
/***********************************************************************/
/* Funtion : exchange */
/* Statement: exchange two datas */
/* */
/* argument : */
/* int *a , int *b */
/* return : */
/* none */
/* */
/***********************************************************************/
void exchange ( int * a , int * b )
{
int t;
t = *a ;
*a = *b ;
*b = t;
}
/***********************************************************************/
/* Funtion : comdays */
/* Statement: compute the days between two dates and return it */
/* */
/* argument : */
/* int a[] , int b[] */
/* return : */
/* int */
/* */
/***********************************************************************/
int comdays( int a[] , int b[] )
{
int n,days=0,mdsum=0,i = 1;
if( dcmp (a,b )==-1) // 确保 a 比 b 早
{
exchange ( &a[0] , &b[0] );
exchange ( &a[1] , &b[1] );
exchange ( &a[2] , &b[2] );
i = -1 ;
}
for ( n = a[0] ; n < b[0] ; n ++ )
if ( IsLeapYear (n) ) days += 366 ;
else days += 365 ;
if ( !IsLeapYear ( a[0] ) ) Month_SumDay[1] = 28;
for ( n = 0 ; n < a[1] - 1 ; n ++ ) mdsum += Month_SumDay[n];
days -= mdsum + a[2] ;
Month_SumDay[1] = 29;
mdsum = 0 ;
if ( !IsLeapYear ( b[0] ) ) Month_SumDay[1] = 28;
for ( n = 0 ; n < b[1] - 1 ; n ++ ) mdsum += Month_SumDay[n];
days += mdsum + b[2] ;
Month_SumDay[1] = 29;
days = i * days ;
if( i==-1) // 确保 a 比 b 早
{
exchange ( &a[0] , &b[0] );
exchange ( &a[1] , &b[1] );
exchange ( &a[2] , &b[2] );
}
//printf ( "It is %d days!\n" , days );
return days;
}
/***********************************************************************/
/* Funtion : dcmp */
/* Statement: compare two dates . */
/* And return the first date is later or earlier than the second.*/
/* if a later the b , return 1 , else return 1 */
/* */
/* argument : */
/* int a[] , int b[] */
/* return : */
/* int */
/* */
/***********************************************************************/
int dcmp ( int a[] ,int b[] )
{
if ( ( a[0] < b[0] ) || ( ( a[0] == b[0] ) && ( a[1] < b[1] ) ) || ( ( a[0] == b[0] ) && ( a[1] == b[1] ) && ( a[2] < b[2] ) ) ) return 1;
if ( ( a[0] > b[0] ) || ( ( a[0] == b[0] ) && ( a[1] > b[1] ) ) || ( ( a[0] == b[0] ) && ( a[1] == b[1] ) && ( a[2] > b[2] ) ) ) return -1;
else return 0;
}
/***********************************************************************/
/* Funtion : tcmp */
/* Statement: compare two times . */
/* And return the first time is later or earlier than the second.*/
/* if a later the b , return 1 , else return 1 */
/* */
/* argument : */
/* int a[] , int b[] */
/* return : */
/* int */
/* */
/***********************************************************************/
int tcmp ( int a[] ,int b[] )
{
if ( ( a[0] < b[0] ) || ( ( a[0] == b[0] ) && ( a[1] < b[1] ) ) ) return 1;
if ( ( a[0] > b[0] ) || ( ( a[0] == b[0] ) && ( a[1] > b[1] ) ) ) return -1;
else return 0;
}
/***********************************************************************/
/* Funtion : calibration_week */
/* Statement: calibrate two weeks .if there is no click */
/* return 1 ,else return 0. */
/* argument : */
/* struct mission *ptr, struct mission *head */
/* return : */
/* int */
/* */
/***********************************************************************/
int calibration_week ( struct mission *ptr, struct mission *head )
{
int i ;
for ( i = 0 ; i < 7 ; i ++ )
if ( ptr -> wdate == 1 && head ->wdate == 1 ) return 0;
return 1 ;
}
/***********************************************************************/
/* Funtion : calibration_date */
/* Statement: calibrate two date .if there is no click */
/* return 1, else return 0. */
/* argument : */
/* struct mission *ptr, struct mission *p */
/* return : */
/* int */
/* */
/***********************************************************************/
int calibration_date ( struct mission *ptr, struct mission *p )
{
printf("ok\n");
if ( ( dcmp ( ptr -> st_date , p -> en_date) != -1 && dcmp ( ptr -> en_date, p -> st_date) != 1 ) || ( dcmp ( p -> st_date , ptr -> en_date) != -1 && dcmp ( p-> en_date , ptr -> st_date ) != 1) ) return 0;
return 1 ;
}
/***********************************************************************/
/* Funtion : check_week */
/* Statement: calibrate two times .if there is no click */
/* return 1 ,else return 0. */
/* argument : */
/* struct mission *ptr, struct mission *head */
/* return : */
/* int */
/* */
/***********************************************************************/
int check_week ( struct mission *p )
{
int i ;
for ( i = 0 ; i < 7 ; i ++ )
if ( p -> wdate == 0 ) return 0 ;
return -1;
}
/***********************************************************************/
/* Funtion : calibration_time */
/* Statement: calibrate two times .if there is no click */
/* return 1 ,else return 0. */
/* argument : */
/* struct mission *ptr, struct mission *head */
/* return : */
/* int */
/* */
/***********************************************************************/
int calibration_time ( struct mission *ptr, struct mission *p )
{
if ( ( tcmp ( ptr -> st_time , p -> en_time) != -1 && tcmp ( ptr -> en_time, p -> st_time) != 1 ) || ( tcmp ( p -> st_time , ptr -> en_time) != -1 && tcmp ( p-> en_time , ptr -> st_time ) != 1) ) return 0;
return 1 ;
}
/***********************************************************************/
/* Funtion : get_date */
/* Statement: get two dates .if it is succeed return 1 */
/* else return 0. */
/* argument : */
/* int *year , int *mon , int *day */
/* return : */
/* int */
/* */
/***********************************************************************/
int get_date(int *year , int *mon , int *day )
{
struct tm *ptr;
time_t lt;
int i,y,m,d,w;
char date[10];
lt=time(NULL);
ptr=localtime(<);
strftime(date,10,"%Y%m%d%w",ptr);
for(i = 0,y = 0,m = 0,d = 0,w = 0;i<10;i++)
{
if(i < 4)
y = y * 10 + date - 48;
if(i >= 4 && i < 6)
m = m * 10 + date - 48;
if(i >= 6 && i < 8)
d = d * 10 + date - 48;
if(i == 8 )
w = date - 48 ;
}
*year = y ;
*mon = m ;
*day = d ;
return w;
}
/***********************************************************************/
/* Funtion : calibration_date */
/* Statement: calibrate two click dates.and go on check */
/* their if click in week.if there is no click return 1 */
/* else return 0. */
/* argument : */
/* struct mission *ptr, struct mission *p */
/* return : */
/* int */
/* */
/***********************************************************************/
int calibration_daybyday ( struct mission *ptr , struct mission *p )
{
int begin[3],end[3],i,num,w, j=0 ;
if ( dcmp ( ptr -> en_date, p -> en_date) != -1 )
for ( i = 0 ; i < 3 ; i ++ )
{
if ( dcmp ( ptr -> st_date , p -> st_date) != -1 )
begin = p -> st_date ;
else begin = ptr -> st_date ;
end = ptr -> en_date ;
}
else for ( i = 0 ; i < 3 ; i ++ )
{
if ( dcmp ( p -> st_date , ptr -> st_date) != -1 )
begin = ptr -> st_date ;
else begin = p -> st_date ;
end = p -> en_date ;
}
num = comdays ( begin , end ) ;
if ( num > 7 ) return 0;
w = get_date( &end[0] , &end[1] , &end[2] ) ;
num = comdays ( begin , end ) ;
j = -1 * (num % 7) + w;
j += 7;
j = j % 7;
for ( i = 0 ; i < num ; i ++ )
{
if ( ptr -> wdate [j] == 1 && p -> wdate[j] == 1 ) return 0 ;
j ++ ;
j = j % 7 ;
}
return 1 ;
}
/***********************************************************************/
/* Funtion : calibration_mission */
/* Statement: calibrate two missions .if there is no click */
/* return 1 ,else return 0. */
/* argument : */
/* struct mission *p1, struct mission *p2 */
/* return : */
/* int */
/* */
/***********************************************************************/
int calibration_mission ( struct mission *p1 , struct mission *p2 )
{
int a , b ;
a = check_week ( p1 );
b = check_week ( p2 );
if ( a != -1 && b != -1 ) // 有限星期和有限星期比较
{
if ( calibration_week( p1 , p2 ) == 0 && calibration_date( p1 , p2 ) == 0 && calibration_daybyday( p1 , p2 ) ==0 )
return 0;
return 1 ;
}
if ( b != a ) // 有限星期和有限日期比较
{
if ( calibration_date( p1 ,p2 ) == 0 && calibration_daybyday ( p1 ,p2 ) == 0 ) return 0 ;
return 1;
}
else // 有限日期之间比较
{
if ( calibration_date( p1 , p2 ) == 0 ) return 0 ;
return 1 ;
}
}
/***********************************************************************/
/* Funtion : check_mission */
/* Statement: check a mission to a chain of a mission . */
/* if there is no click return 1 ,else return 0 */
/* */
/* argument : */
/* struct mission *head, struct mission *ptr */
/* return : */
/* int */
/* */
/***********************************************************************/
int check_mission ( struct mission *head , struct mission *ptr , int m )
{
struct mission * p = head ;
int i =1;
while ( p != NULL )
{
if ( calibration_time ( ptr , p ) == 1 || calibration_mission ( ptr , p ) == 1 || i == m )
{
p = p -> next ;
i++;
}
else return 0 ;
}
return 1;
}
/***********************************************************************/
/* Funtion : returnnextday */
/* Statement: out put the next day'sdate. */
/* */
/* argument : */
/* int *Year,int *Month,int *Day */
/* return : */
/* none */
/* */
/***********************************************************************/
void returnnextday(int *Year,int *Month,int *Day)
{
int ThisMonthSumDay;
ThisMonthSumDay=Month_SumDay[*Month-1];
if (*Month==2)
if (IsLeapYear(*Year)==0) ThisMonthSumDay--;
if (*Day<ThisMonthSumDay)
(*Day)++;
else
{
if (*Day==ThisMonthSumDay)
{
*Day=1 ;
if (*Month==12)
{ printf("%d--1 ",*Year);
(*Year)++;printf("%d--2 ",*Year);
*Month=1;
}
else (*Month)++;
}
}
}
/***********************************************************************/
/* Funtion : returnlastday */
/* Statement: out put the last day'sdate. */
/* */
/* argument : */
/* int *Year,int *Month,int *Day */
/* return : */
/* none */
/* */
/***********************************************************************/
void returnlastday(int *Year,int *Month,int *Day)
{
int ThisMonthSumDay;
if ( *Day == 1 )
{
if ( *Month == 1 )
{
*Month == 12 ;
(*Year) -- ;
}
else (*Month) -- ;
ThisMonthSumDay = Month_SumDay[*Month-1];
if ( *Month == 2 )
if ( IsLeapYear(*Year) == 0 ) ThisMonthSumDay --;
*Day = ThisMonthSumDay ;
}
else (*Day) -- ;
}
/***********************************************************************/
/* Funtion : scanwweek */
/* Statement: scan whick week day you want */
/* */
/* argument : */
/* struct mission *ptr */
/* return : */
/* struct mission * */
/* */
/***********************************************************************/
struct mission * scanweek(struct mission * p)
{
int a[7] ={0};
int i=0, j=0;
char b='a',c='a';
printf("please input how much days a week:\n");
scanf("%d", &i);
printf("input number 0-6 as Sunday to Saturday, like 035 stand for Sunday, Thursday and Friday\n");
printf("the number is:\n");
for ( ; i >= 0 ; i -- )
{
b = getchar() ;
switch ( b )
{
case '1' : a[1] = 1; break;
case '2' : a[2] = 1; break;
case '3' : a[3] = 1; break;
case '4' : a[4] = 1; break;
case '5' : a[5] = 1; break;
case '6' : a[6] = 1; break;
case '0' : a[0] = 1; break;
}
}
for(i=0;i<7;i++)
{
p -> wdate = a;
}
return(p);
}
/***********************************************************************/
/* Funtion : compression */
/* Statement: compress the start date and end date */
/* */
/* argument : */
/* struct mission *ptr */
/* return : */
/* struct mission * */
/* */
/***********************************************************************/
struct mission *compression ( struct mission *ptr )
{
int begin[3], end[3] , now[3],i, w , num,k;
for ( i = 0 ; i < 3 ; i ++ )
{
begin = ptr -> st_date ;
end = ptr -> en_date ;
}
w = get_date( &now[0] , &now[1] , &now[2] );
num = comdays ( begin , now ) ;
w = -1 * (num % 7) + w;
w += 7;
w = w % 7;
i = w ;
while ( ptr -> wdate == 0 )
{
returnnextday( &begin[0] , &begin[1] , &begin[2] );
i ++;
i = i % 7;
}
w = get_date( &now[0] , &now[1] , &now[2] );
num = comdays ( end , now ) ;
w = -1 * (num % 7) + w;
w += 7;
w = w % 7;
i = w ;
while ( ptr -> wdate == 0 )
{
returnlastday( &end[0] , &end[1] , &end[2] );
i --;
i = i + 7;
i = i % 7;
}
for ( i = 0 ; i < 3 ; i ++ )
{
ptr -> st_date = begin ;
ptr -> en_date = end ;
}
return ptr ;
}
/***********************************************************************/
/* Funtion : input */
/* Statement: input all data ,return it is secceed or not */
/* */
/* argument : */
/* struct mission *ptr */
/* return : */
/* int */
/* */
/***********************************************************************/
int input(struct mission *p1,int m)
{
int i = 0 ;
int k = 0 ;
char c ;
for(i=0;i<7;i++)
p1->wdate = 1;
printf("please input the program name:\n");
scanf("%s",&p1->name);
printf("\n");
printf("input the start date\n");
if ( !scandate( (int *) &p1->st_date[0], (int *) &p1->st_date[1], (int *) &p1->st_date[2]) ) return 0;
printf("\n");
printf("input the start time\n");
if( !scantime( (int *) &p1->st_time[0], (int *) &p1->st_time[1]) ) return 0;
printf("\n");
if ( m == 1 )
{
for ( i = 0 ; i < 3 ; i ++ )
p1 -> en_date = p1 ->st_date ;
do
{
printf ( "please input finish time :\n");
if( !scantime( (int *) &p1->en_time[0], (int *) &p1->en_time[1]) ) return 0;
k = tcmp(p1->st_time,p1->en_time);
if ( k != 1 ) printf ( " Illogical time input !\n" );
} while ( k != 1 );
}
else // m == 2 || m ==3 ;
{
printf("would you like to input the finish date,if yes please input any key , else input 0:");
scanf("%s",&c);
if ( c == '0' )
{
p1->en_date[0] = 2500;
p1->en_date[1] = 1;
p1->en_date[2] = 1;
}
else // i == any sinal except 0 ;
do
{
printf("input the finish date\n");
if ( !scandate( (int *) &p1->en_date[0], (int *) &p1->en_date[1], (int *) &p1->en_date[2]) ) return 0;
printf("\n");
k = dcmp(p1->st_date,p1->en_date);
if ( k != 1 ) printf ( "Illogical date input !\n" );
} while ( k != 1 ) ;
do
{
if( !scantime( (int *) &p1->en_time[0], (int *) &p1 -> en_time[1] ) ) return 0;
k = tcmp(p1->st_time,p1->en_time);
if ( k == 0 ) printf ( " Illogical time input !\n" );
} while ( k == 0 );
}
if(m == 2)
{
p1 = scanweek(p1);
compression ( p1 );
}
else
{
for(i=0;i<7;i++)
p1->wdate=1;
}
return(1);
}
/*/////////////////////////////////////add by guo in 4.25///////////////////////////////////*/
/******************************************************/
/* Function name: browse */
/* Instruction: browse all mission,and return total */
/* number of mission. */
/* argument: */
/* struct mission * head */
/* return: */
/* int */
/******************************************************/
int browse(struct mission * head)
{
struct mission * p = head;
int num = 0; /* mission number */
int i;
if(head != NULL)
{
printf("\nNow,all mission records are: \n");
printf("NUM\tNAME\t\tSTART TIME\tEND TIME\tWEEK\n",num+1,&p->name);
if(head != NULL)
do{
printf("%d\t%-8s\t",num+1,&p->name);
printf("%d.%d.%d\t%d.%d.%d\t",p->st_date[0],p->st_date[1],p->st_date[2],p->en_date[0],p->en_date[1],p->en_date[2]);
if(check_week(p) != -1)
for(i = 0; i < 7; i++)
{ if(p->wdate == 1)
switch(i)
{
case 0 : printf("Sun "); break;
case 1 : printf("Mon "); break;
case 2 : printf("Tue "); break;
case 3 : printf("Wed "); break;
case 4 : printf("Thu "); break;
case 5 : printf("Fri "); break;
case 6 : printf("Sat "); break;
};
}
printf("\n\t\t\t%d:%d\t\t%d:%d\n",p->st_time[0],p->st_time[1],p->en_time[0],p->en_time[1],p->st_date[0]);
p = p->next;
num++;
}while(p != NULL);
}
return(num);
}
/************************************************************************/
/* Function name: delete */
/* Instruction: delete single mission,and return head. */
/* argument: */
/* struct mission * head, int n */
/* return: */
/* struct mission * head */
/************************************************************************/
struct mission * delete(struct mission * head,int n)
{
struct mission * p1, * p2;
int i;
if(head == NULL){printf("\nList null!!!\n"); return(head);}
p1 = head;
for(i = 1; i < n; i++)
{ p2 = p1;
p1 = p1->next;
}
if(p1 == head)
head = p1->next;
else p2->next = p1->next;
printf("\n--*--*--Remove mission(%d) finished!--*--*--\n",n);
if(head == NULL)
printf("\nhead = NULL\n");
return(head);
}
/************************************************************************/
/* Function name: struct mission * int add(struct misson * head, int m)*/
/* Instruction: add in misson,return 1 for succeed,0 for fail. */
/* argument: */
/* struct mission * head, int m */
/* return: */
/* struct mission * head */
/************************************************************************/
struct mission * add(struct mission * head)
{
struct mission * p,* p1;
int k;
p1 = (struct mission *) malloc (LEN);
do
{
printf("************************************\n");
printf("* Witch type do you want : *\n");
printf("* *\n");
printf("* 1.Single preengaging. *\n");
printf("* 2.Week preengaging. *\n");
printf("* 3.Continuous preengaging. *\n");
printf("* 0.Return to main menu. *\n");
printf("* *\n");
printf("************************************\n");
printf("Please enter your choise:");
scanf("%d",&k);
}while(k>3 || k<0);
if(k == 0) return(head);
if( ! input(p1,k) )
return(head);
p = head;
if( head != NULL )
{
if( check_mission( p1, head, 0 ) == 0 )
{
printf ( "It is a conflict.\n" );
return(head);
}
while( p -> next != NULL ) p = p -> next;
p -> next = p1;
p1 -> next = NULL;
}
else{
head = p1;
p1->next = NULL;
}
return(head);
}
/**********************************************/
/* Function name: read_file() */
/* Instruction: read file and creat struct. */
/* */
/* argument: */
/* void */
/* return: */
/* struct mission * head */
/**********************************************/
struct mission * read_file(void)
{
FILE * fp;
struct mission * head;
struct mission * p1, * p2;
int n = 0;
head = NULL;
if((fp = fopen("mission.txt","r")) == NULL)
{ printf("\n--*--*--Can not open file!--*--*--\n");
return(head);
}
while(!feof(fp))
{
n = n + 1;
p1 = (struct mission * )malloc(LEN);
if(n == 1) head = p1;
else p2->next = p1;
fscanf(fp,"%[^,],%d.%d.%d,%d:%d,%d.%d.%d,%d:%d\n",&p1->name , &p1->st_date[0] , &p1->st_date[1] , &p1->st_date[2] , &p1->st_time[0] , &p1->st_time[1],&p1->en_date[0],&p1->en_date[1],&p1->en_date[2],&p1->en_time[0],&p1->en_time[1]);
p2 = p1;
}
p2->next = NULL;
fclose(fp);
printf("\n--*--*--Read file finished!--*--*--\n");
return(head);
}
/**********************************************/
/* Function name: write_file */
/* Instruction: write the stuct to file,and */
/* return 1 for succeed,0 for fail. */
/* argument: */
/* struct mission * head */
/* return: */
/* int */
/**********************************************/
int write_file(struct mission * head)
{
FILE * fp;
struct mission * p1 = head;
if((fp = fopen("mission.txt","w+")) == NULL)
{ printf("\n--*--*--Can not open file!--*--*--\n");
return(0);
}
for(;p1 != NULL;p1 = p1->next)
{
fprintf(fp,"%s,%d.%d.%d,%d:%d,%d.%d.%d,%d:%d\n",p1->name , p1->st_date[0] , p1->st_date[1] , p1->st_date[2] , p1->st_time[0] , p1->st_time[1],p1->en_date[0],p1->en_date[1],p1->en_date[2],p1->en_time[0],p1->en_time[1]);
}
fclose(fp);
return(1);
}
/******************************************************/
/* Function name: change */
/* Instruction: change int misson and return head. */
/* argument: */
/* struct misson * head , int n */
/* return: */
/* struct misson * head */
/******************************************************/
struct mission *change(struct mission *head, int n)
{
int i,k;
int j = 0;
struct mission * p, * p1, * p2;
p1 = (struct mission *) malloc (LEN);
p = head;
p2 = head;
for(j = 1 ; j < n-1 ; j ++ )
p2 = p2->next;
for(j = 1 ; j < n ; j ++ )
p = p->next;
printf("%d\t%-8s\t",n,&p->name);
printf("%d.%d.%d\t%d.%d.%d\t",p->st_date[0],p->st_date[1],p->st_date[2],p->en_date[0],p->en_date[1],p->en_date[2]);
if(check_week(p) != -1)
for(i = 0; i < 7; i++)
{ if(p->wdate == 1)
switch(i)
{
case 0 : printf("Sun "); break;
case 1 : printf("Mon "); break;
case 2 : printf("Tue "); break;
case 3 : printf("Wed "); break;
case 4 : printf("Thu "); break;
case 5 : printf("Fri "); break;
case 6 : printf("Sat "); break;
};
}
printf("\n\t\t\t%d:%d\t\t%d:%d\n",p->st_time[0],p->st_time[1],p->en_time[0],p->en_time[1],p->st_date[0]);
do
{
printf("************************************\n");
printf("* Witch type do you want : *\n");
printf("* *\n");
printf("* 1.Single preengaging. *\n");
printf("* 2.Week preengaging. *\n");
printf("* 3.Continuous preengaging. *\n");
printf("* 0.Return to main menu. *\n");
printf("* *\n");
printf("************************************\n");
printf("Please enter your choise:");
scanf("%d",&k);
}while(k>3 || k<0);
if(k == 0) return(head);
if ( ! input(p1, k) )
{ printf("\nMission error1! Please enter again!\n");
return(head);
}
if ( ! check_mission( p1,head,(j-1) ) )
{ printf("\nMission error2! Please enter again!\n");
return(head);
}
if(p == head)
{
head = p1;
p1->next = p->next;
}
else
{ p2->next = p1;
p1->next = p->next;
}
return(head);
} |
|