Demo entry 6354726

1

   

Submitted by anonymous on Apr 10, 2017 at 14:48
Language: C. Code size: 1.4 kB.

void modify()//查询并修改
{
	char name[20], num[20];
	int a, j, x, flag;

	printf("1.按学号查询\n");
	printf("2.按姓名查询\n");
	printf("请输入:");
	scanf("%d", &x);
	switch (x)
	{
	case 1: {
		printf("请输入学期、学号:");
		scanf("%d%s", &a, num);
		for (j = 0;j < i;j++)
		{
			if (a == stu[j].sem&&strcmp(num, stu[j].num) == 1)
			{
				printf("学期:%d    学号:%s    班级:%d    姓名:%s    语文:%.0f    数学:%.0f    英语:%.0f    计算机:%0.f\n", stu[j].sem, stu[j].num, stu[j].cla, stu[j].name, stu[j].y, stu[j].s, stu[j].w, stu[j].c);
				printf("是否需要修改(1.是 0.否):");
				scanf("%d", &flag);
				if (flag == 1)
				{
					printf("请输入修改后的语文数学英语计算机成绩:");
					scanf("%f%f%f%f", &stu[j].y, &stu[j].s, &stu[j].w, &stu[j].c);
					printf("修改成功");
				}
			}
		}
	}break;
	case 2: {
		printf("输入学期、学生姓名:");
		scanf("%d%s", &a, name);
		for (j = 0;j <= i;j++)
		{
			if (a == stu[j].sem&&strcmp(name, stu[j].name) == 1)
			{
				printf("学期:%d    学号:%s    班级:%d    姓名:%s    语文:%.0f    数学:%.0f    英语:%.0f    计算机:%0.f\n", stu[j].sem, stu[j].num, stu[j].cla, stu[j].name, stu[j].y, stu[j].s, stu[j].w, stu[j].c);
				printf("是否需要修改(1.是 0.否):");
				scanf("%d", &flag);
				if (flag == 1)
				{
					printf("请输入修改后的语文数学英语计算机成绩:");
					scanf("%f%f%f%f", &stu[j].y, &stu[j].s, &stu[j].w, &stu[j].c);
					printf("修改成功");
				}
			}
		}
	}break;
	default:printf("error");break;
	}
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).