马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
如题所示#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
void main()
{
int menu(int i);
int i, j, k,m;
char a[100] = "123456",/*管理员密码*/ b[100];
printf("Welcome to the course Management interface\n");
printf("please input a number between 0 and 4\n");
printf("0 to 4 means English,Math, C language, History and Administrator interface\n");
scanf("%d",&i);
for(; i > 4 || i < 0;) //如果不在0到4之间则提示输入错误,并重新输入
{
printf("error\nplease input again\n");
scanf("%d",&i); //此处用到了整型变量i;
}
if(i == 4) //(一重if)判断输入的值是否为4,若是4则进入管理员密码页面,否则退回上一页面
{
printf(" Please enter the administrator password\n");//输入管理员密码,如果正确则获得管理员权限,如果不对提示错误并退出
gets(b);/*
就是这个gets(b);
刚才还是好好的,为什么现在不行了
手动分割线..............................................................................................................................................................................................................................................
*/
for(m = 0; b[m]!='\n'; m++ )
{
if(a[m] !=b[m] )
{
printf("wrong password\n");
printf("please input again");
m = 0;
gets(b);
}
}
}
//好像可以不要这个判断语句if(a[] == b[m]) //(二重if)
{
printf("Congratulations on obtaining administrator rights\n");
printf("Please enter what you want to modify\n (subject information means 0 Administrator password means 1)\n");
scanf("%d",&k); //此处用到了整型变量k;
for(; k > 1||k < 0;)
{
printf("error\nplease input again\n");
scanf("%d",&k);
}
if(k == 1) //(三重if)
{
printf("Please input new password");
gets(a);
printf("success!");
system("pause"); //按任意键继续
}
else //(三重if)的else 三重if出来了
{
printf("0 to 2 means English, Math, C language and History");
scanf("%d",&j);
for(; j > 2&&j < 0;)
{
printf("error\nplease input again");
}
/*
printf("plaese input information you want to modify");
if(j = 0) 不知道在主函数在修改其他函数的值
{
scanf("%s%s%s%s%s",)
} */
}
}
}
/*
int menu(int i)
struct subject
{
char name[80]; //课程名称
char num[80]; //课号
char teacher[80]; //任课老师
char way[80]; //考核方式
char point[80]; //学分
} str[4] = {
{"English", "GB2001", "Li lei", "Open book examination", "two points"},
{"Math", "GB2002", "Han Meimei", "Closed book exam", "four points"},
{"C language", "GB2003", "Xiao Jiayu", "Closed-book exam", "five points"},
{"History", "GB2004", "Chen Rui", "Half open book exam", "two points"}
};
printf("name is %s\t num is %7s\nteacher is %s\t way is %s\npoint is %s\n",str[0].name,str[0].num,str[0].teacher,str[0].way,str[0].point);
*/
|