first commit

master
黄黄育皓 7 years ago
commit 89bce3392a

@ -0,0 +1,148 @@
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#include<string.h>
#define M 10 //宏定义评委人数
struct player //结构体定义选手
{
int num;
char name[8];
int score[M];
};
void Intplayer(struct player a[],int n) //输入选手数据函数
{
int i;
printf("请输入参赛歌手的人数:");
scanf("%d",&n);
printf("请输入歌手的学号和姓名:\n");
for(i=0;i<n;i++)
scanf("%d %s",&a[i].num,&a[i].name);
}
void sort(struct player a[],float b[],int n) //排序函数
{
int i,k,j,t;
float temp;
char str[8];
for(i=0;i<n;i++)
{
k=i;
for(j=i+1;j<n;j++)
if(b[k]>b[j])
k=j;
if(k!=i)
{
temp=b[i];
b[i]=b[k];
b[k]=temp;
strcpy(str,a[i].name);
strcpy(a[i].name,a[k].name);
strcpy(a[k].name,str);
t=a[i].num;
a[i].num=a[k].num;
a[k].num=t;
}
}
}
void main()
{
system("color F4"); //白底红字
int flag=1,n,i,m,j,r;
FILE *fp;
fp = fopen("data.txt","w+"); //文件写入位置
struct player a[20];
float aver[99]={0};
int sum[99]={0};
int Max[99];
int Min[99];
int add=2;
printf(" 歌手比赛系统主菜单\n");
printf("************************************************************\n");
printf(" **********1.输入选手数据***********\n");
printf(" **********2.评委打分***************\n");
printf(" **********3.成绩排序***************\n");
printf(" **********4.数据查询***************\n");
printf(" **********5.追加学生数据***********\n");
printf(" **********6.写入数据文件***********\n");
printf(" **********7.退出系统***************\n");
printf("*************************************************************\n\n\n\n");
while(flag)
{
printf("请输入你想进行的操作:");
scanf("%d",&r);
switch(r)
{
case 1:
Intplayer(a,n); //调用输入数据函数
break;
case 2:
printf("请输入1中人数");
scanf("%d",&n);
for(i=0;i<n;i++) //参赛人数循环
{
printf("%d号选手得分情况\n",i+1);
for(j=0;j<M;j++) //评委打分循环
{
printf("第%d位评委打分",j+1);
scanf("%d",&a[i].score[j]);
}
}
break;
case 3:
printf("请输入1中人数");
scanf("%d",&n);
for(i=0;i<n;i++)
{
Max[i]=a[i].score[0];
Min[i]=a[i].score[0];
for(j=0;j<M;j++) //判断某选手得分最大最小值
{
sum[i]+=a[i].score[j];
if(Max[i]<a[i].score[j])
Max[i]=a[i].score[j];
if(Min[i]>a[i].score[j])
Min[i]=a[i].score[j];
}
aver[i]=(float)(sum[i]-Max[i]-Min[i])/(M-2);
}
sort(a,aver,n); //调用排序函数
for(i=0;i<n;i++)
printf("%s %5.2f\n",a[i].name,aver[i]);
break;
case 4:
printf("你想查询选手的数据:");
scanf("%d",&m);
for(i=0;i<n;i++)
if(a[i].num==m)
{
printf("%d号选手%s总分:%d,最高分%d,最低分%d,平均分%5.2f",a[i].num,a[i].name,sum[i],Max[i],Min[i],aver[i]);
printf("\n");
}
break;
case 5:
printf("请输入要追加的选手数据:\n");
add += 1;
scanf("%d %s",&a[add].num,&a[add].name);
break;
case 6:printf("将数据写入文件中:\n");
for (i = 0 ; i < add+1 ; i++)
{
fprintf(fp,"%d ",a[i].num);
fprintf(fp,"%s ",a[i].name);
fprintf(fp,"%d\n",a[i].score);
}
break;
case 7:exit(0);
break;
default:flag=0;
}
}
}

@ -0,0 +1,88 @@
# Microsoft Developer Studio Project File - Name="Cpp2" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=Cpp2 - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "Cpp2.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "Cpp2.mak" CFG="Cpp2 - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Cpp2 - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "Cpp2 - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "Cpp2 - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x804 /d "NDEBUG"
# ADD RSC /l 0x804 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "Cpp2 - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE RSC /l 0x804 /d "_DEBUG"
# ADD RSC /l 0x804 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "Cpp2 - Win32 Release"
# Name "Cpp2 - Win32 Debug"
# Begin Source File
SOURCE=.\Cpp2.cpp
# End Source File
# End Target
# End Project

Binary file not shown.

Binary file not shown.

@ -0,0 +1,32 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: Cpp2 - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\Users\Uncle\AppData\Local\Temp\RSP9939.tmp" with contents
[
/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"Debug/Cpp2.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
"D:\2345Downloads\Cpp2.cpp"
]
Creating command line "cl.exe @C:\Users\Uncle\AppData\Local\Temp\RSP9939.tmp"
Creating temporary file "C:\Users\Uncle\AppData\Local\Temp\RSP9949.tmp" with contents
[
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/Cpp2.pdb" /debug /machine:I386 /out:"Debug/Cpp2.exe" /pdbtype:sept
.\Debug\Cpp2.obj
]
Creating command line "link.exe @C:\Users\Uncle\AppData\Local\Temp\RSP9949.tmp"
<h3>Output Window</h3>
Compiling...
Cpp2.cpp
Linking...
<h3>Results</h3>
Cpp2.exe - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save