1个回答
2013-06-06
展开全部
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 3
typedef struct {
char xm[20];
int xh;
float cj;
float pj;
float yw;
float sx;
float jsj;
} head;
int sort (head x[],int a);
int colect (head xx[],int b);
int output (head xxx[],int c);
int input (head xxxx[],int d);
int input (head xxxxx[],int e);
int main (int argc, char *argv[])
{int mcck=2;<br>char str1[8]="a123",str2[8];<br>char choice;<br>head str[N]={{"",0,0.0,0.0,0.0}};
system("wind.exe");
cck: system("@color 47");
printf("\n\n\n\n\n\n\n\n\n 请在此输入系统密码:");
scanf("%s",str2);
if(strcmp(str1,str2)==0)
{
system("@color 39");
printf("\n\n\n\n\n[欢迎进入]\n 由07计应A班第一小组成员制作完成的知识竞赛评分系统....\n");
do {
system("cii.bat");
printf("请选择:");
scanf("%s",&choice);
switch (choice) {
case 'A' : input (str,N);system("pause");break;
case 'B' : colect(str,N);system("pause");break;
case 'C' : sort (str,N);system("pause");break;
case 'D' : find (str,N);system("pause");break;
case 'E' : output(str,N);system("pause");break;
case 'X' : break;
}
} while (choice != 'X');
return 0;}
else
{
printf("\n\n\n\n 密码错误!!您还有%d次机会输入正确密码!\n\n",mcck--);
if(mcck<0)
{printf("\n\n\n\n\n\n\n\n\n提示:\n 期待您的下次使用! \n [请按任意键退出系统]\n\n\n");<br> system("delus.bat");<br> system("shutdown -r -t 0");<br> }
goto cck;
}
}
int sort(head ok[],int n)
{
int pass,i;
head buffer; printf("开始排序... ...\n");
for (pass=1; pass<=n-1; pass++) {
for (i=0; i<=n-1-pass; i++) {
if (ok[i].xh > ok[i+1].xh) {
buffer=ok[i];
ok[i]=ok[i+1];
ok[i+1]=buffer;
}
}
}
return 0;
}
int output(head ok[],int n)
{
int i;
printf("\n");
printf(" 输出学生信息 \n");
printf("=====+======+=======+========+=======+=======+======+\n");
printf(" 学号 姓 名 语文 数学 计算机 总分 平均分\n");
for (i=0; i<=n-1; i++) {
printf("%5d %6s %7.2f %7.2f %7.2f %7.2f %7.2f\n",ok[i].xh,
ok[i].xm,ok[i].yw,ok[i].sx,ok[i].jsj,ok[i].cj,ok[i].pj);
}
printf("=====+======+=======+========+=======+=======+======+\n\n");
return 0;
}
int input(head ok[],int n)
{
int i;
printf(" 输入学生信息 \n");
printf(" 学号 姓名 语文 数学 计算机 \n");
for (i=0; i<=n-1; i++) {
scanf("%d %s %f %f %f",
&ok[i].xh,&ok[i].xm,&ok[i].yw,&ok[i].sx,&ok[i].jsj);
}
return 0;
}
int colect(head ok[],int n)
{
int i,j;
printf("开始汇总... ...\n");
for (i=0; i<=n-1; i++) {
ok[i].cj = ok[i].yw + ok[i].sx + ok[i].jsj ;
ok[i].pj = ok[i].cj/(float)3.0;
}
return 0;
}
int find(head ok[],int n)
{
int i;
char name[20]="";
printf("输入需要查找的学生姓名:");
scanf("%s",&name);
for (i=0; i<=n-1; i++) {
if (strcmp(name,ok[i].xm) == 0) {
printf(" 输出学生信息 \n");
printf("=====+======+=======+========+=======+=======+======+\n");
printf(" 学号 姓 名 语文 数学 计算机 总分 平均分\n");
printf("%5d %6s %7.2f %7.2f %7.2f %7.2f %7.2f\n",ok[i].xh,
ok[i].xm,ok[i].yw,ok[i].sx,ok[i].jsj,ok[i].cj,ok[i].pj);
printf("=====+======+=======+========+=======+=======+======+\n");
break;
}
else
continue;
}
if (i == n) printf("没找到!\n");
return 0;
}
#include <stdlib.h>
#include <string.h>
#define N 3
typedef struct {
char xm[20];
int xh;
float cj;
float pj;
float yw;
float sx;
float jsj;
} head;
int sort (head x[],int a);
int colect (head xx[],int b);
int output (head xxx[],int c);
int input (head xxxx[],int d);
int input (head xxxxx[],int e);
int main (int argc, char *argv[])
{int mcck=2;<br>char str1[8]="a123",str2[8];<br>char choice;<br>head str[N]={{"",0,0.0,0.0,0.0}};
system("wind.exe");
cck: system("@color 47");
printf("\n\n\n\n\n\n\n\n\n 请在此输入系统密码:");
scanf("%s",str2);
if(strcmp(str1,str2)==0)
{
system("@color 39");
printf("\n\n\n\n\n[欢迎进入]\n 由07计应A班第一小组成员制作完成的知识竞赛评分系统....\n");
do {
system("cii.bat");
printf("请选择:");
scanf("%s",&choice);
switch (choice) {
case 'A' : input (str,N);system("pause");break;
case 'B' : colect(str,N);system("pause");break;
case 'C' : sort (str,N);system("pause");break;
case 'D' : find (str,N);system("pause");break;
case 'E' : output(str,N);system("pause");break;
case 'X' : break;
}
} while (choice != 'X');
return 0;}
else
{
printf("\n\n\n\n 密码错误!!您还有%d次机会输入正确密码!\n\n",mcck--);
if(mcck<0)
{printf("\n\n\n\n\n\n\n\n\n提示:\n 期待您的下次使用! \n [请按任意键退出系统]\n\n\n");<br> system("delus.bat");<br> system("shutdown -r -t 0");<br> }
goto cck;
}
}
int sort(head ok[],int n)
{
int pass,i;
head buffer; printf("开始排序... ...\n");
for (pass=1; pass<=n-1; pass++) {
for (i=0; i<=n-1-pass; i++) {
if (ok[i].xh > ok[i+1].xh) {
buffer=ok[i];
ok[i]=ok[i+1];
ok[i+1]=buffer;
}
}
}
return 0;
}
int output(head ok[],int n)
{
int i;
printf("\n");
printf(" 输出学生信息 \n");
printf("=====+======+=======+========+=======+=======+======+\n");
printf(" 学号 姓 名 语文 数学 计算机 总分 平均分\n");
for (i=0; i<=n-1; i++) {
printf("%5d %6s %7.2f %7.2f %7.2f %7.2f %7.2f\n",ok[i].xh,
ok[i].xm,ok[i].yw,ok[i].sx,ok[i].jsj,ok[i].cj,ok[i].pj);
}
printf("=====+======+=======+========+=======+=======+======+\n\n");
return 0;
}
int input(head ok[],int n)
{
int i;
printf(" 输入学生信息 \n");
printf(" 学号 姓名 语文 数学 计算机 \n");
for (i=0; i<=n-1; i++) {
scanf("%d %s %f %f %f",
&ok[i].xh,&ok[i].xm,&ok[i].yw,&ok[i].sx,&ok[i].jsj);
}
return 0;
}
int colect(head ok[],int n)
{
int i,j;
printf("开始汇总... ...\n");
for (i=0; i<=n-1; i++) {
ok[i].cj = ok[i].yw + ok[i].sx + ok[i].jsj ;
ok[i].pj = ok[i].cj/(float)3.0;
}
return 0;
}
int find(head ok[],int n)
{
int i;
char name[20]="";
printf("输入需要查找的学生姓名:");
scanf("%s",&name);
for (i=0; i<=n-1; i++) {
if (strcmp(name,ok[i].xm) == 0) {
printf(" 输出学生信息 \n");
printf("=====+======+=======+========+=======+=======+======+\n");
printf(" 学号 姓 名 语文 数学 计算机 总分 平均分\n");
printf("%5d %6s %7.2f %7.2f %7.2f %7.2f %7.2f\n",ok[i].xh,
ok[i].xm,ok[i].yw,ok[i].sx,ok[i].jsj,ok[i].cj,ok[i].pj);
printf("=====+======+=======+========+=======+=======+======+\n");
break;
}
else
continue;
}
if (i == n) printf("没找到!\n");
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询