Home > Back-end >  Someone is willing to look at me this long code..
Someone is willing to look at me this long code..

Time:10-09

I want to ask a few questions, hope to have who can help me answer:
1. Input the students after login again, how to judge the students have to make an appointment, I tried to use STRCMP function, let enter student id and deposited in the file of student number, the same means to make an appointment, but I tried it on, the input and the last time the same student id, STRCMP function show different,
2. When teachers see students booking situation, how to do it, as shown in the figure, especially the student number and period of time, how did he do in the same article number, (the picture from top to bottom respectively is a date, make an appointment time, booking number, number, booking appointments classmate student id)

#include
#include
#include
int num=0;
Int w=0;
Int teacher1 ();
Int teacher2 ();
Struct the teacher teacher3 ();
Struct the teacher teacher4 (int I);
Struct the teacher teacher5 (int I);
Int student1 ();
Int student2 ();
Int student3 (int j);
Int student4 (int j);
Int yu ();
Struct the teacher
{
Char time [11].
Int a, [13].
Int b [13].
Int d [13].
Int sum;
} t [100];
Int main ()
{
T [0]. Sum=0;
While (1)
{
Int n;
Printf (" * * this is curriculum design rejoin reservation system * * \ n ");
Printf (" please enter 1 teachers, students, please enter 2: \ n ");
The scanf (" % d ", & amp; N);
If (n==1)
{
Teacher1 ();
break;
}
Else if (n==2)
{
Student1 ();
break;
}
The else
{
Printf (" you input is wrong, please input again, \ n \ n ");
continue;
}
}
return 0;
}
Int teacher1 ()
{
FILE *fp;
If ((fp=fopen (" file1. Dat ", "wb"))==NULL)
{
Printf (" build file error \ n ");
return 0;
}
The fclose (fp);
int j;
Char a [8], [8] b={' t ', 'e', 'a', 'c', 'h', 'e', 'r'};
While (1)
{
Printf (" please input the correct user id: \ n ");
Printf (" please input the teacher (teachers) \ n ");
The scanf (" % s ", a);
J=STRCMP (a, b);
If (j==0)
break;
The else

Printf (" you input is wrong, please input again, \ n \ n ");
}
If (num!=0)
Yu ();
Teacher2 ();
return 0;
}
Int yu ()
{
FILE *fp;
If ((fp=fopen (" file1. Dat ", "rb"))==NULL)
{
Printf (" build file error! \n");
return 0;
}
int i;
for (i=0; I & lt;=1; I++)
Fread (& amp; T [I], sizeof (struct the teacher), 1, fp);
The fclose (fp);
int j;
For (j=0; J & lt;=1; J++)
{

Int j, k;
Printf (" booking date: ");
Printf (" % s \ n "t [j]. Journal of time).
Printf (" can make an appointment time: ");
For (m=1; M & lt; 13; M++)
Printf (" % 5 d, m);
printf("\n");
Printf (" booking number: ");
For (k=0; k <12. K++)
Printf (" % 5 d, t [j]. J b [k]);
printf("\n");
Int e;
Printf (" booking number: ");
For (e=0; E & lt; 12. E++)
Printf (" % 5 d, t [j]. J d [e]);
Printf (" \ n \ n ");
}
return 0;
}
Int teacher2 ()
{
Int a, b, c, I;
Printf (" please enter the booking date of reply: \ n ");
Printf (" format for: XXXX - xx - xx (year, month, day) \ n ");
Printf (" (in the middle of the bar with a minus sign in place of) \ n ");
The scanf (" % s ", t [num] time);
If (num & gt;
=1){
FILE *fp;
If ((fp=fopen (" file1. Dat ", "rb"))==NULL)
{
Printf (" build file error \ n ");
return 0;
}
Int x;
For (x=0; X & lt; Num. X++)
Fread (& amp; T [x], sizeof (struct the teacher), 1, fp);
for (i=0; I & lt; Num. I++)
If (STRCMP (t) [r]. Num time, t [I] time)==0)
{
Printf (" input the date you have to repeat, please input again, \ n ");
Teacher2 ();
}
The fclose (fp);
}

If (num==1)
T [num] d [4]=1;
T [num]. [12] d='\ 0';
A=(t) [r]. Num time [0] - 48) * 1000 + (t) [r]. Num time [1] - 48) * 100 + (t) [r]. Num time [2] - 48) * 10 + (t) [r]. Num time [3] - 48).
B=(t) [r]. Num time [5] - 48) * 10 + (t) [r]. Num time [6] - 48).
C=(t) [r]. Num time [8] - 48) * 10 + (t) [r]. Num time [9] - 48).
If (b & lt;=0 | | b> 12)
{
Printf (" you input is wrong, please input again, \ n \ n ");
Teacher2 ();
}
Else if (c & lt;=0 | | c & gt; 31)
{
Printf (" you input is wrong, please input again, \ n \ n ");
Teacher2 ();
}
Else if (a % 4==0) & amp; & (b==2) & amp; & (c & gt;=30))
{
Printf (" you input is wrong, please input again, \ n \ n ");
Teacher2 ();
}
Else if ((a % 4!=0) & amp; & (b==2) & amp; & (c & gt;=29))
{
Printf (" you input is wrong, please input again, \ n \ n ");
Teacher2 ();
}
Else if (((b=4) | | (b=6) | | (b=9) | |=11) (b) & amp; & (c==31))
{
Printf (" you input is wrong, please input again, \ n \ n ");
Teacher2 ();
}
The else
{
If (num==0)
{
Int j, y;
For (y=0; Y & lt;=100; Y++)
For (j=0; J & lt; 12. J++)
T [y]. [j] d={0};
}
Teacher3 ();
}
return 0;
}
Struct the teacher teacher3 ()
{
Int I=0;
Printf (" please enter the booking period: \ n ");
Printf (" (time by 1-12 class division) \ n ");
Printf (" (each time for different Spaces, enter the end with 0) please \ n ");
While (1)
{
The scanf (" % d ", & amp; T [num] a [I]);
If (t [num] a [I]==0)
{
T [num] a [I + 1)='\ 0';
Teacher4 (I);
break;
}
i++;
}
Return the t (num);
}
Struct the teacher teacher4 (int I)
{
Int k;
For (k=0; k <12. K++)
T [num]. [k] b=0;
int j;
For (j=0; J & lt; i; J++)
{printf (" please enter the first booking number: % d time \ n ", t [num] a [j]);
Printf (" (each class rejoin fewer than 5 more appropriate) \ n ");
The scanf (" % d ", & amp; [t [num]. B (t [num] a [j] 1)]);
}
Teacher5 (I);
Return the t (num);
}
Struct the teacher teacher5 (int I)
{
Int n;
{
Printf (" please enter 1 continues to set the date, \ n ");
Printf (" preview set an appointment please enter 2, \ n ");
Printf (" exit this role, please enter 0 \ n ");
The scanf (" % d ", & amp; N);

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related