?? evo03.cpp
字號:
cout<<"\n\n ______________________________________\n";
if (st==0||st==1)
cout<<"N=發布公告 D=刪除公告\n";
cout<<"0~9=查看公告 X=返回主菜單\n";
do
{
flag=0;
c=getch();
if (c=='x'||c=='X')
{
fclose(fpa);
return 0;
}
if (c>='0'&&c<('0'+an))
{
temp=c-'0';
system("CLS");
printf("標題:%s\n",a[temp].title);
printf("發布人:%s 發布日期:%s\n________________________________________________________________________________\n",a[temp].fbz,a[temp].date);
cout<<a[temp].content;
printf ("\n\n\n________________________________________________________________________________\n按X鍵返回上一層\n");
fflush(stdin);
while (c1=getch(),c1!='x'&&c1!='X')
;
flag=1;
}
else if(st==0||st==1)
{
if (c>='A'&&c<='Z')
c+=32;
switch (c)
{
case 'n':system("CLS");
if (an==9)
{
cout<<"公告條已達到最大限,發布前請刪除部分公告,保證有足夠空間發布新公告\n";
system("pause");
flag=1;
}
else
{
cout<<"請輸入主題:\n";
gets(a[an].title);
strcpy(a[an].fbz,usn);
time.wYear=2008;
t=&time;
GetLocalTime(t);
for (j=1000,i=0;i<4;i++,j/=10)
a[an].date[i]=((time.wYear/j)%10)+'0';
a[an].date[i]='-';
a[an].date[5]=time.wMonth/10+'0';
a[an].date[6]=time.wMonth%10+'0';
a[an].date[7]='-';
a[an].date[8]=time.wDay/10+'0';
a[an].date[9]=time.wDay%10+'0';
a[an].date[10]='\0';
cout<<"請輸入公布內容(CTRL+D結束輸入)\n";
inputflag=0;
while (cinput=getch(),cinput!=4)
{
if (cinput=='\b')
{
if (inputflag>=2&&a[an].content[inputflag-2]>=128)
{
printf("\b\ \b");
inputflag-=2;
}
else
{
if (inputflag>0)
printf("\b \b");
inputflag--;
}
}
else
{
if (cinput==13)
{
cout<<"\n";
a[an].content[inputflag++]='\n';
}
else
{
a[an].content[inputflag++]=cinput;
cout<<a[an].content[inputflag-1];
}
}
}
a[an].content[inputflag]='\0';
an++;
cout<<"\n\n發表成功\n";
system("pause");
flag=2;//2 for changed
}
break;
case'd':cout<<"請輸入你要刪除的公告編碼\n\nX=取消操作\n";
while (c1=getch(),(c1>'0'&&c1<an+'0')&&c1!='x'&&c1!='X')
;
if (c1=='x'||c1=='X')
{
flag=1;//1 for next
break;
}
else
{
cout<<"確定要刪除"<<(c1-'0')<<"號公告嗎?\n\nY=確定 N=取消\n";
while (c2=getch(),c2!='y'&&c2!='Y'&&c2!='n'&&c2!='N')
;
if (c2=='y'||c2=='Y')
{
strcpy(a[c1-'0'].date,"0000-00-00");
an--;
flag=2;
}
else
{
flag=1;
break;
}
}
break;
}
}
if (flag==2)
{
qsort(a,10,sizeof(a[0]),anccmp);
rewind(fpa);
fprintf (fpa,"%d\n",an);
for (i=0;i<an;i++)
{
fprintf(fpa,"$%s$%s$%s$\n%d\n%s\n",a[i].title,a[i].fbz,a[i].date,strlen(a[i].content),a[i].content);
}
}
}while(flag==0);
}
}
int chkinfo()
{
int i,lr_flag=0,sj;
char c;
system("CLS");
while (1)
{
if (lr_flag==0)
{
system("CLS");
printf ("%10s%12s%6s%12s%12s%12s\n________________________________________________________________________________\n","姓名","學號","性別","學院專業","政治面貌","籍貫");
for (i=0;i<stu_num;i++)
printf ("%10s%12s%6s%12s%12s%12s\n",stu[i].name,stu[i].num,stu[i].sex,stu[i].pro,stu[i].pstat,stu[i].jg);
printf ("\n________________________________________________________________________________\n");
printf ("R=滾動到右半頁 X=回到主菜單\n");
while (c=getch(),c!='x'&&c!='X'&&c!='r'&&c!='R')
;
if (c=='r'||c=='R')
lr_flag=1;
if (c=='x'||c=='X')
{
system("CLS");
return 0;
}
}//end left
else
{
system("CLS");
printf ("%10s%12s%16s%36s\n________________________________________________________________________________\n","姓名","生日","宿舍電話","郵箱");
for (i=0;i<stu_num;i++)
printf ("%10s%12s%16s%36s\n",stu[i].name,stu[i].birth,stu[i].tel,stu[i].mail);
printf ("\n________________________________________________________________________________\n");
printf ("L=滾動到左半頁 X=回到主菜單\n");
while (c=getch(),c!='x'&&c!='X'&&c!='l'&&c!='L')
;
if (c=='l'||c=='L')
lr_flag=0;
if (c=='x'||c=='X')
{
system("CLS");
return 0;
}
}//end right
}
}
int amdinfo()
{
int i,j,flag,lr_flag=0,fsflag=0,slr_flag=0,flr_flag=0,sj,this_flag,cflag,thislr_flag,amdflag,slct,found,deleteflag,amd_cflag,chongfu,findf;
char c,csj,str[11];
system("CLS");
while (1)
{
fsflag=0;
if (lr_flag==0)
{
system("CLS");
printf ("%10s%12s%6s%12s%12s%12s\n________________________________________________________________________________\n","姓名","學號","性別","學院專業","政治面貌","籍貫");
for (i=0;i<stu_num;i++)
printf ("%10s%12s%6s%12s%12s%12s\n",stu[i].name,stu[i].num,stu[i].sex,stu[i].pro,stu[i].pstat,stu[i].jg);
printf ("\n________________________________________________________________________________\n");
printf ("F=查找(修改) S=排序\n");
printf ("R=滾動到右半頁 X=回到主菜單\n");
while (c=getch(),c!='x'&&c!='X'&&c!='r'&&c!='R'&&c!='f'&&c!='F'&&c!='s'&&c!='S')
;
if (c=='r'||c=='R')
lr_flag=1;
if (c=='x'||c=='X')
{
qsort(stu,stu_num,sizeof(stu[0]),cmp_save);
system("CLS");
return 0;
}
if (c=='f'||c=='F')
fsflag=1;//1 for 查找
else if (c=='s'||c=='S')
fsflag=2;//2 for 排序
}//end left
else
{
system("CLS");
printf ("%10s%12s%16s%21s\n________________________________________________________________________________\n","姓名","生日","宿舍電話","郵箱");
for (i=0;i<stu_num;i++)
printf ("%10s%12s%16s%21s\n",stu[i].name,stu[i].birth,stu[i].tel,stu[i].mail);
printf ("\n________________________________________________________________________________\n");
printf ("F=查找(修改) S=排序\n");
printf ("L=滾動到左半頁 X=回到主菜單\n");
while (c=getch(),c!='x'&&c!='X'&&c!='l'&&c!='L'&&c!='f'&&c!='F'&&c!='s'&&c!='S')
;
if (c=='l'||c=='L')
lr_flag=0;
if (c=='x'||c=='X')
{
system("CLS");
return 0;
}
if (c=='f'||c=='F')
fsflag=1;//1 for 查找
else if (c=='s'||c=='S')
fsflag=2;//2 for 排序
}//end right
if (fsflag==2)
{
cout<<"________________________________________________________________________________\n\n";
cout<<"\n選擇排序...\nN=姓名排序 U=學號排序 S=性別排序 P=專業排序\nO=政治面貌排序 J=籍貫排序 B=生日排序 X=取消\n";
while (c=getch(),c!='n'&&c!='N'&&c!='u'&&c!='U'&&c!='s'&&c!='S'&&c!='p'&&c!='P'&&c!='o'&&c!='O'&&c!='j'&&c!='J'&&
c!='b'&&c!='B'&&c!='x'&&c!='X')
;
if (c!='x'&&c!='X')
{
cout<<"________________________________________________________________________________\n\n";
cout<<"\n排序順序...I=升序 D=降序\n";
while (csj=getch(),csj!='i'&&csj!='I'&&csj!='d'&&csj!='D')
;
for (i=0;i<stu_num;i++)
stu_flag[i]=i;
if (csj=='i'||csj=='I')
sj=1;
if (csj=='d'||csj=='D')
sj=-1;
if (c=='n'||c=='N')
qsort (stu,stu_num,sizeof (stu[0]),cmpn);
if (c=='u'||c=='U')
qsort (stu,stu_num,sizeof (stu[0]),cmpu);
if (c=='s'||c=='S')
qsort (stu,stu_num,sizeof (stu[0]),cmps);
if (c=='p'||c=='P')
qsort (stu,stu_num,sizeof (stu[0]),cmpp);
if (c=='o'||c=='O')
qsort (stu,stu_num,sizeof (stu[0]),cmpo);
if (c=='j'||c=='J')
qsort (stu,stu_num,sizeof (stu[0]),cmpj);
if (c=='b'||c=='B')
qsort (stu,stu_num,sizeof (stu[0]),cmpb);
cout<<"排序完畢!\n";
}
}//end 排序
if (fsflag==1)
{
cout<<"________________________________________________________________________________\n\n";
cout<<"N=查找姓名 U=查找學號 X=返回\n";
while (c=getch(),c!='n'&&c!='N'&&c!='u'&&c!='U'&&c!='x'&&c!='X')
;
if(c=='n'||c=='N')
{
found=1;
cout<<"________________________________________________________________________________\n\n";
cout<<"請輸入你要查找的姓名\n";
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -