#include stdio.h
在朗县等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供网站制作、网站建设 网站设计制作定制设计,公司网站建设,企业网站建设,品牌网站制作,营销型网站建设,成都外贸网站建设,朗县网站建设费用合理。
#define N 100
/*定义学生结构体*/
struct Student
{
int 稿余ID;
char Name[20];
float Mark1;
float Mark2;
float Mark3;
float Sum;
};
/*声明学生数组及学生数量则态*/
struct Student students[N];
//int num=0;
/*求总分*/
float Sums(struct Student stu)
{
return stu.Mark1+stu.Mark2+stu.Mark3;
}
/*输入学生信息*/
int Student_Input(){
int num=0;
while(1){
//printf("请输入学号:");
students[num].ID=num+1; //可以自行将学号改为手工输入
printf("请输入姓名:");
scanf("%s",students[num].Name);
getchar();
printf("请输入成绩1:");
scanf("%f",students[num].Mark1);
getchar();
printf("请输入成绩2:");
scanf("%f",students[num].Mark2);
printf("请输入成绩3:");
scanf("%f",students[num].Mark3);
getchar();
students[num].Sum=Sums(students[num]);
num++;
printf("是否继续?(y/n)"); //继续输入数据?
if (getchar()=='n'){
break;
孙敬源 }
}
return num;
}
/*输出学生信息*/
void Student_Display(int n)
{
int i;
printf("%10s%10s%8s%8s%8s%8s\n","学号","姓名","成绩","成绩","成绩","总成线");
printf("---------------------------------------------------------\n");
for (i=0;in;i++)
{
printf("%10d%10s%8.2f%8.2f%8.2f%8.2f\n",students[i].ID,students[i].Name,
students[i].Mark1,students[i].Mark2,students[i].Mark3,students[i].Sum);
}
}
/*主程序*/
int main(){
int n=0;
n=Student_Input();
Student_Display(n);
return 0;
}
很缺李岩简单嘛
#include "stdio.h"
#include "stdlib.h"
#define N 3
struct student
{
char num[6];
char name[10];
int score[3];
float average;
}stu[N];
int main(void)
{
void print(struct student stu[10]);
int i,j;
for(i=0;iN;i++)
{
printf("input No.: ");
scanf("%s",stu[i].num);
printf("Name: ");
scanf("%s",stu[i].name);
for(j=0;j3;j++)
{ printf("伏御input score: ");
scanf("%d",stu[i].score[j]); }
}
print(stu);
system("pause");
return 0;
}
void print(struct student stu[10])
{
float ave=0;
int i,j,temp=0;
int fscore;
for(i=0;iN;i++)
{ ave=0;
for(j=0;j3;j++)
{
ave+=stu[i].score[j];
stu[i].average=ave/5;
}
}
for(i=0;iN;i++)
{
printf("No. %s Name:%s average:%5.2f\n",
stu[i].num,stu[i].name,stu[i].average);
for(j=0;j3;j++)
printf("score: %d\n",stu[i].score[j]);
}
fscore=stu[0].score[0];
for(i=0;iN;i++)
{for(j=0;j3;j++)
if(fscore扰蔽stu[i].score[j])
temp=i;
}
printf("\nthe best student is : \n");
printf("No. %s Name:%s average:%5.2f\n",
stu[temp].num,stu[temp].name,stu[temp].average);
printf("input score:\n");
for(j=0;j3;j++)
printf("score: %d\n",stu[temp].score[j]);
}
以前写的 现在学C++了
#includestdio.h
double 知态getsum(double*a)
{
double ans=0;
for(int i=0;i10;i++)
ans+=a[i];
return ans;
}
double getavg(double sum)
{
return sum/10;
}
int main()
{
double a[10];
for(int i=0;i10;i++)scanf("缓斗%lf"扰猛磨,a[i]);
double sum=getsum(a);
printf("%lf %lf\n",sum,getavg(sum));
return 0;
}