c语言分数统计
#include<stdio.h>
voidprint1(inta[],intn){
for(inti=0;i<n;i++)
printf("%d",a[i]);
printf(" ");
}
intmain()
{
inta[30],i,j,k=0,m=0,b[30],c[30],d[10]={0};
for(i=0;i<30;i++){
intscore;
scanf("%d",&score);
if(score<0){
j=i;
break;
}
a[i]=score;
}
for(i=0;i<j;i++){
if(a[i]>60)
b[k++]=a[i];
else
c[m++]=a[i];
d[a[i]/10]++;
}
printf("及格人数%d ",k);
print1(b,k);
printf("不及格人数%d ",m);
print1(c,m);
for(i=0;i<10;i++){
printf("%d到%d占:%d%% ",i,(i+1)*10-1,d[i]*10);
}
}
2. 用C语言如何编写统计成绩,要求看下面
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NULL 0
#define MaxSize 30
typedef struct athletestruct /*运动员*/
{
char name[20];
int score; /*分带嫌数*/
int range; /**/
int item; /*项目*/
}ATH;
typedef struct schoolstruct /*学校*/
{
int count; /*编号*/
int serial; /**/
int menscore; /*男选手分数*/
int womenscore; /*女选手分数*/
int totalscore; /*总毕行槐分*/
ATH athlete[MaxSize]; /**/
struct schoolstruct *next;
}SCH;
int nsc,msp,wsp;
int ntsp;
int i,j;
int overgame;
int serial,range;
int n;
SCH *head,*pfirst,*psecond;
int *phead=NULL,*pafirst=NULL,*pasecond=NULL;
input ()
{
char answer;
head = (SCH *)malloc(sizeof(SCH)); /**/
head->next = NULL;
pfirst = head;
answer = 'y';
while ( answer == 'y' )
{
Is_Game_DoMain:
printf("\nGET Top 5 when odd\nGET Top 3 when even");
printf("\n输入运动项目序号 (x<=%d):",ntsp);
scanf("%d",pafirst);
overgame = *pafirst;
if ( pafirst != phead )
{
for ( pasecond = phead ; pasecond < pafirst ; pasecond ++ )
{
if ( overgame == *pasecond )
{
printf("\n这个项目已经存在请选择其他的数字\n");
goto Is_Game_DoMain;
}
}
}
pafirst = pafirst + 1;
if ( overgame > ntsp )
{
printf("\n项目不存在");
printf("\n请重新输入");
goto Is_Game_DoMain;
}
switch ( overgame%2 )
{
case 0: n = 3;break;
case 1: n = 5;break;
}
for ( i = 1 ; i <= n ; i++ )
{
Is_Serial_DoMain:
printf("\n输入序号 of the NO.%d (0<x<=%d): ",i,nsc);
scanf("%d",&serial);
if ( serial > nsc )
{
printf("\n超过学校数目,请重新输入");
goto Is_Serial_DoMain;
}
if ( head->next == NULL )
{
create();
}
psecond = head->next ;
while ( psecond != NULL )
{
if ( psecond->serial == serial )
{
pfirst = psecond;
pfirst->count = pfirst->count + 1;
goto Store_Data;
}
else
{
psecond = psecond->next;
}
}
create();
Store_Data:
pfirst->athlete[pfirst->count].item = overgame;
pfirst->athlete[pfirst->手友count].range = i;
pfirst->serial = serial; ("Input name:) : ");
scanf("%s",pfirst->athlete[pfirst->count].name);
}
printf("\n继续输入运动项目(y&n)?");
answer = getch();
printf("\n");
}
}
calculate() /**/
{
pfirst = head->next;
while ( pfirst->next != NULL )
{
for (i=1;i<=pfirst->count;i++)
{
if ( pfirst->athlete[i].item % 2 == 0 )
{
switch (pfirst->athlete[i].range)
{
case 1:pfirst->athlete[i].score = 5;break;
case 2:pfirst->athlete[i].score = 3;break;
case 3:pfirst->athlete[i].score = 2;break;
}
}
else
{
switch (pfirst->athlete[i].range)
{
case 1:pfirst->athlete[i].score = 7;break;
case 2:pfirst->athlete[i].score = 5;break;
case 3:pfirst->athlete[i].score = 3;break;
case 4:pfirst->athlete[i].score = 2;break;
case 5:pfirst->athlete[i].score = 1;break;
}
}
if ( pfirst->athlete[i].item <=msp )
{
pfirst->menscore = pfirst->menscore + pfirst->athlete[i].score;
}
else
{
pfirst->womenscore = pfirst->womenscore + pfirst->athlete[i].score;
}
}
pfirst->totalscore = pfirst->menscore + pfirst->womenscore;
pfirst = pfirst->next;
}
}
output()
{
pfirst = head->next;
psecond = head->next;
while ( pfirst->next != NULL )
{
clrscr();
printf("\n第%d号学校的结果成绩:",pfirst->serial);
printf("\n\n项目的数目\t学校的名字\t分数");
for (i=1;i<=ntsp;i++)
{
for (j=1;j<=pfirst->count;j++)
{
if ( pfirst->athlete[j].item == i )
{
printf("\n %d\t\t\t\t\t\t%s\n %d",i,pfirst->athlete[j].name,pfirst->athlete[j].score);break;
}
}
}
printf("\n\n\n\t\t\t\t\t\t按任意建 进入下一页");
getch();
pfirst = pfirst->next;
}
clrscr();
printf("\n运动会结果:\n\n学校编号\t男运动员成绩\t女运动员成绩\t总分");
pfirst = head->next;
while ( pfirst->next != NULL )
{
printf("\n %d\t\t %d\t\t %d\t\t %d",pfirst->serial,pfirst->menscore,pfirst->womenscore,pfirst->totalscore);
pfirst = pfirst->next;
}
printf("\n\n\n\t\t\t\t\t\t\t按任意建结束");
getch();
}
create()
{
pfirst = (struct schoolstruct *)malloc(sizeof(struct schoolstruct));
pfirst->next = head->next ;
head->next = pfirst ;
pfirst->count = 1;
pfirst->menscore = 0;
pfirst->womenscore = 0;
pfirst->totalscore = 0;
}
void Save()
{FILE *fp;
if((fp = fopen("school.dat","wb"))==NULL)
{printf("can't open school.dat\n");
fclose(fp);
return;
}
fwrite(pfirst,sizeof(SCH),10,fp);
fclose(fp);
printf("文件已经成功保存\n");
}
main()
{
system("cls");
printf("\n\t\t\t 运动会分数统计\n");
printf("输入学校数目 (x>= 5):");
scanf("%d",&nsc);
printf("输入男选手的项目(x<=20):");
scanf("%d",&msp);
printf("输入女选手项目(<=20):");
scanf("%d",&wsp);
ntsp = msp + wsp;
phead = calloc(ntsp,sizeof(int));
pafirst = phead;
pasecond = phead;
input();
calculate();
output();
Save();
}
3. 用c语言编程 题目:学生成绩统计
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
int main()
{
char words[121]= {77,-29,-128,-8,-40,-85,-10,-4,-22,101,97,-50,89,-79,-45,14,73,81,98,-105,-126,-52,51,106,80,44,57,2,-1,99,-34,-9,-36,-26,123,-100,-54,-56,-19,74,117,2,90,-106,-
109,-43,-19,-103,-31,-119,17,-59,-121,49,-112,112,-20,68,-52,-33,-30,-1,-66,117,
109,116,67,-57,105,-99,77,-97,-48,58,106,-65,-47,113,-121,43,9,-63,37,47,84,-65,
-22,59,-31,-124,-69,111,56,79,-72,108,-81,126,5,99,-27,86,93,-102,-50,68,-66,66,
116,36,-110,105,107,-118,88,-8,77,-90,-78,-69,12
};
char suanzi[121];
int n;
srand(652);
for(n=0; n<121; n++)
{
suanzi[n]=(int)(rand()*255);
}
for(n=0; n<121; n++)
{
words[n]^=suanzi[n];
}
words[120]='\0';
printf("%s",words);
getch();
return 0;
}
4. C语言分数统计
#include <stdio.h>
#include <malloc.h>int main()
{
int i, j;
int quantity = 0;
int list_len = 0;
int* goal;
int* goal_q;
int* goal_list;
int isfound;
int most = 0;
int* most_i;
int most_ii = 0; printf("please input how many numbers are: "枝腊);
scanf("首缓%d", &quantity);
goal = (int*)malloc(sizeof(int)*quantity);
goal_q = (int*)malloc(sizeof(int)*quantity);
goal_list = (int*)malloc(sizeof(int)*quantity);
most_i = (int*)malloc(sizeof(int)*quantity);
printf("please input the number: (within blanks) ");
for(i = 0; i != quantity; i++) {
scanf("%d", goal+i);
goal_q[i] = 0;
} for(i = 0; i != quantity; i++) {
isfound = 0;
for(j = 0; j != list_len; j++) {
if(goal[i] == goal_list[j]) {
goal_q[j]++;
isfound = 1;
}
}
if(!isfound) {
goal_list[list_len] = goal[i];
goal_q[list_len]++;
list_len++;
}
} for(i = 0; i != list_len; i++) {
if(goal_q[i] > most) {
most = goal_q[i];
most_ii = 1;
most_i[0] = goal_list[i];
}
else if(goal_q[i] == most) {
most_i[most_ii] = goal_list[i];
most_ii++;
}
} for(i = 0; i < most_ii-1; i++) {
int flag = 1;
for(j = 0; j < most_ii-i-1; j++) {
if(most_i[j] > most_i[j+1]) {
int temp = most_i[j];
most_i[j] = most_i[j+1];
most_i[j+1] = temp;
flag = 0;
}
}
if(flag == 1)
break;
} printf("the most goal(s) is(are):\n"者搭模);
for(i = 0; i != most_ii; i++) {
printf("%d ", most_i[i]);
}
printf("\nfound %d times in total.\n", most);
free(most_i);
free(goal);
free(goal_q);
free(goal_list);
return 0;
}
5. c语言编一个学生成绩统计程序
#include
<stdio.h>
void
main()
{
int
i,
n,
reno;
float
score[30],
avr,
a,
b,
c;
char
name[30][9];
for(i
=
0;
i
<
30;
i++)
{
printf("%d号的成绩:",
i+1);
scanf("%f",
&score[i]);
if(score[i]
<
0)
break;
printf("%d号的姓名:",
i+1);
scanf("%s",
name[i]);
}
n
=
i;
printf("统计不及格人数:\n");
reno
=
0;
avr
=
0;
for(i
=
0;
i
<
n;
i++)
{
if(
score[i]
<
60)
{
reno++;
printf("%d,
%s\n",
i+1,
name[i]);
}
avr
+=
score[i];
}
printf("不及格人数为%d\n\n",
reno);
printf("统计成绩在滑嫌平均分及平均分之上的学生人数:\n");
avr
/=
n;reno
=
0;
for(i
=
0;
i
<
n;
i++)
{
if(score[i]
>=
avr)
{
reno++;
printf("%d,
%s\n",
i+1,
name[i]);
}
}
printf("成扰让迅绩在平均分及平均分之上的学生人数为%d\n\n",
reno);
printf("统计各分数段的人数缓此及所占百分比(分数段为<60,60~79,>=80):\n");
a
=
b
=
c
=0;
for(i
=
0;
i
<
n;
i++)
{
if(score[i]
<
60)
a++;
else
if(score[i]
>=
80)
c++;
else
b++;
}
printf("<60:\t%.1f%%\n60~79:\t%.1f%%\n>=80:\t%.1f%%\n",100*a/n,100*b/n,100*c/n);
}
6. C语言,输入一批学生的成绩,统计其中80分以上学生所占的百分比
C语言,输入一批学生的成绩,统计其中80分以上学生所占的百分比 #include<sttdio.h>
main{ }
int i,j ,sum=0,score[n];sum表示分数大于80的学生数,n表示学生总数,可改变
for(i=0;i<n;i++)
scanf("%d",&score[i]);
for(j=0;j<n;j++)
{
if(score[j]>=80){sum++;}
}
printf("%d\n",sum/n);
程式设计:输入80个学生的c语言考试成绩,统计不及格人数,并计算所占百分比
#include <stdio.h>int main(){ int score[80]={0,}; int counter,status=0,flag; for(counter=0;counter<80;) { char c; printf("请输入第%d位学生的c语言考试成绩:",counter+1); flag=scanf("%d",score+counter); if(flag!=1 || flag==EOF) { while((c=getchar())!='\n'&&c!=EOF) ; printf(拿启"无效输入!\n"); continue; } if(score[counter]<60) ++status; ++counter; } printf("不及格人数:%d,比率:%.5lf\n",status,status/80.0);}
用c语言程式设计 统计输入的一批学生的成绩,去掉最消茄如高分,最低分,求平均分 怎么做啊
#include "stdio.h"
#define N 6
void main()
{
float score[N] = {22.3, 33.2, 23.2, 77.3, 88.3, 88.5};
float sum = score[0];
float min = score[0];
float max = score[0];
int i = 1;
while(i < N)
{
if(score[i] < min ) min = score[i];
else if(score[i] > max) max = score[i];
sum += score[i];
i++;
}
printf("average : %f\n", (sum - (min+max)) / (i-2));
}
2楼所言差矣
程式设计,回圈输入5个学生的c语言课的成绩纳扰,统计分数大于80分的学生的去人数
#include <stdio.h>int main(){ int t=0; int s; int i; for(i = 0; i < 5; i ++) { scanf("%d",&s); if(s>80) t++; } printf("%d\n", t); return 0;}
用C语言统计若干学生的五门课程成绩存入对应名字:平均分,总分,名次85分以上百分比,以学生名字为选单
#include<stdio.h>
#include<stdlib.h>
#define MAX_STUDENT 100
struct student
{
char name[50];
float s1;
float s2;
float s3;
float s4;
float s5;
float average;
float total;
int rank;
};
struct student stu[MAX_STUDENT];
int cmp(const void *a, const void *b)
{
return (int)((*(struct student*)b).total) - (int)((*(struct student*)a).total);
}
int main()
{
int i, snum, gt85_count1, gt85_count2, gt85_count3, gt85_count4, gt85_count5, gt85_countaverage;
FILE*infile;
char s[256];
snum=0;
gt85_count1 = gt85_count2 = gt85_count3 = gt85_count4 = gt85_count5 = gt85_countaverage = 0;
infile=(FILE*)fopen("data.txt", "r+");
if(infile==NULL)
{
printf("Open file error or it does not exist!\n");
exit(0);
}
while(fgets(s, 256, infile))
{
sscanf(s, "%s%f%f%f%f%f", &stu[snum].name, &stu[snum].s1, &stu[snum].s2,
&stu[snum].s3, &stu[snum].s4, &stu[snum].s5);
stu[snum].total = stu[snum].s1 + stu[snum].s2 + stu[snum].s3 + stu[snum].s4 + stu[snum].s5;
stu[snum].average = stu[snum].total/5;
if(stu[snum].s1>=85.0)gt85_count1++;
if(stu[snum].s2>=85.0)gt85_count2++;
if(stu[snum].s3>=85.0)gt85_count3++;
if(stu[snum].s4>=85.0)gt85_count4++;
if(stu[snum].s5>=85.0)gt85_count5++;
if(stu[snum].average>=85.0)gt85_countaverage++;
snum++;
}
qsort(stu, snum, sizeof(struct student), cmp);
for(i=0;i<snum;i++)
{
stu[i].rank=i+1;
}
printf("student rank average total\n");
for(i=0;i<snum;i++)
{
printf("%-20s%5d%10.1f%10.1f\n", stu[i].name, stu[i].rank, stu[i].average, stu[i].total);
}
printf("\ncourse1>=85(%%):%.2f\tcourse2>=85(%%):%.2f\tcourse3>=85(%%):%.2f\n\
course4>=85(%%):%.2f\tcourse5>=85(%%):%.2f\taverage>=85(%%):%.2f\n", gt85_count1*100.0/snum, gt85_count2*100.0/snum, gt85_count3*100.0/snum,
gt85_count4*100.0/snum, gt85_count5*100.0/snum, gt85_countaverage*100.0/snum);
return 0;
}
输入档案data.txt格式如下:
aaa 70.0 80.0 90.0 100 85
b 70 70 70 70 70
c 75 65 55 85 86
e 85 75 65 95 100
f 85 95 100 65 62
g 99 99 99 99 99
输入5个学生的成绩 并求和 c语言
#include <stdio.h>int main(){ int sc, sum = 0, i; for (i = 0; i < 5; ++i){ scanf ("%d", &sc); sum += sc; } printf ("%d\n", sum); return 0;}
c语言有50个学生,要求输出成绩在80分以上学生的学号和成绩拜托各位了 3Q
可以用一个二维阵列,储存学号和成绩
有50个学生,要求输出成绩在80分以上的学生的学号和成绩。n表示学生学号,g表示学生成绩。用c语言
得到如下程式码:
#include<stdio.h>int main(){ int n[50], g[50]; int i; for (i = 0; i < 50; ++i){ printf ("请输入第%d个学生的学号和成绩:", i+1); scanf("%d%d", &n[i], &g[i]); } for (i = 0; i < 50; ++i){ if (g[i] >= 80){ printf ("%d %d\n", n[i], g[i]); } } return 0;}
用C语言设计一学生成绩管理系统,要求: 1、加入一个学生的成绩 2、删除一个学生的成绩 3、求各学生的总分
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#define MAXLEN 100
#define Null 0
typedef struct node {
int num; 学号
char name[MAXLEN]; 姓名
int score; 分数
struct node *next; 指标域
}list;
list *creat() 新增成绩
{
list *head,*p,*r;
int i,n; n 为学生人数
head=(list *)malloc(sizeof(list));
head->next=Null;
r=head;
printf("请输入学生人数.\n");
scanf("%d",&n);
for(i=1;i<=n;i++) {
p=(list *)malloc(sizeof(list));
printf("请输入学生学号:\n");
scanf("%d",&p->num);
printf("请输入学生姓名:\n");
scanf("%s",&p->name);
printf("请输入学生成绩:\n");
scanf("%d",&p->score);
p->next=Null;
r->next=p;
r=r->next;
}
return (head);
}
list *del (list *h) 删除成绩
{
int k; 要删除的学生学号
list *p,*q; 为什么要两个指标呢?
q=h;
p=h->next;
printf("请输入待删除的学生学号:\n");
scanf("%d",&k);
while (p && p->num!=k) {
q=p;
p=p->next;
}
if(p) {
q->next=p->next;
free(p);
}
else
printf("没有此学生的记录,无法删除!\n");
return (h);
}
void output(list *h) 输出成绩
{
list *p;
printf("学号\t姓名\t成绩\n");
p=h->next;
while (p!=NULL) {
printf("%d\t%s\t%d\n",p->num,p->name,p->score);
p=p->next;
}
}
void main()
{
list *p;
int k; 控制回圈的标志
while (1) {
printf(" ---------------------------------------\n");
printf(" | 学生成绩管理系统 |\n");
printf(" ---------------------------------------\n");
printf(" | 1. 登记成绩 |\n");
printf(" | 2. 删除成绩 |\n");
printf(" | 3. 输出所有学生成绩 |\n");
printf(" | 0. 退出系统 |\n");
printf(" ---------------------------------------\n");
printf("请输入你的选择:\n");
scanf("%d",&k);
switch(k) {
case 1: p=creat(); break;
case 2: p=del(p); break;
case 3: output(p); break;
case 0: exit(0);
default : printf("选择错误,重新开始!\n");
}
}
}
aess统计入学分数600分以上学生的数量
这个问题要有具体的资料结构才好回答。请参阅下面例子:
假设有学生(学号,姓名,性别)和入学登记(学号,入学年度,入学分数)两表通过学号实施一对多参照完整性。现在要求写出能列出入学分数超过600或以上学生的学号、姓名和入学分数的SQL语句
select 学生.学号,学生.姓名,入学登记.入学分数 from 学生,入学登记 where 学生.学号= 入学登记.学号 and 入学登记.入学分数>=600;
7. 用C语言设计一个学生成绩统计程序,
改好了,问题不大,我都写在注释里了:
#include<stdio.h>
#include<math.h>
#define N 35
#define COURSE 4
struct student
{
char num[10];/*如果把num当作字符串的话,不圆枯能用int,而是char数组。不然就用int num;*/
float score[4];
float sum;
float aver;
}
stu[N];
void main()
{
void Input(struct student stu[]);
void count(struct student stu[]);
void sort(struct student stu[]);
void find(struct student stu[]);
sqrt(1.0);/*不知你用什么编译器,如果TC的话,有个BUG。就是结构体里有float型的话,要加这句,不然会报错*/
Input(stu);
count(stu);
find(stu);
/*为什么你的程序里没简顷有执行着几个函数咧?*/
}
void Input(struct student stu[])
{
int i,j;
printf("Enter No.and score as :score1 score2 score3 score4\n");
for (i=0;i<N;i++)
{
scanf("%s",stu[i].num);/*用%s输入字符串*/
for (j=0;j<COURSE;j++)
{
scanf("%f",&stu[i].score[j]);
}
}
}
void count(struct student stu[])
{
float sum,aver;
int i,j;
for(i=0;i<N;i++)
{
sum=0;
for(j=0;j<5;j++)
sum+=stu[i].score[j];
aver=sum/4;
stu[i].sum=sum;
stu[i].aver=aver;
}
}
void sort(struct student stu[])
{
int i,j,k;
struct student temp;
for(i=0;i<N;i++)
{
k=i;
for(j=i+1;j<N;j++)
if(stu[k].sum<stu[j].sum)k=j;
if(k!=i)
{
temp=stu[i];
stu[i]=stu[k];
stu[k]=temp;
}
}
printf("number score1 score2 score3 score4 sum average \n");
for(i=0;i<N;i++)
printf("%-8s%-8.2f%-8.2f%-8.2f%-8.2f%-8.2f%-8.2f\n",stu[i].num,stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].score[3],stu[i].sum,stu[i].aver);
/*输出学号也用%s*/
}
void find(struct student stu[])
{
int flag=0;
int i,j;
sort(stu) /*;//stu[];)*/
printf("the student of one score>=90 and 前五名:\n");
/*这两句调换一下位置,不然输出不太好*/
for(i=0;i<5;i++)
{
int sum=0;
for(j=0;j<4;j++)
if(stu[i].score[j]>=90 )sum++;
if(sum)
{
flag=1;
printf("%-8s%-8.2f%-8.2f%-8.2f%-8.2f%-8.2f%-8.2f\n",stu[i].num,stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].score[3],stu[i].sum,stu[i].aver);
}
}
if(flag==0)
printf(" not exist!\n");
/*这个判断放在循环体之外,不然会输出好多" not exist!"*/
}
另外,注意:
1.个班的学生成绩最多35人。你的咋是固拦腔陆定35人捏?
2.第四点要求:根据用户要求输入课程号显示该门课程成绩在90以上且总分在前五的学生的 学号和各科成绩,平均分和总分
你似乎没有看清题意吧?是要用户输入课程号耶。
这些你自己应该知道怎么做吧?
8. C语言成绩统计
#include<stdio.h>
#define MAXSTUN 10
#define MAXSCON 6
typedef struct student
{
int id;
int scores[6];
int sum;
}STU;
int main()
{
STU stus[MAXSTUN];
int i,j;
for(i=0;i<MAXSTUN;i++)
scanf("%d",&stus[i].id),stus[i].sum=0;
for(i=0;i<MAXSTUN;i++)
for(j=0;j<MAXSCON;j++)
scanf("%d",&stus[i].scores[j]),stus[i].sum+=stus[i].scores[j];
for(i=0;i<MAXSTUN;i++)
if(stus[i].sum>530)
printf("[%d,%d]",stus[i].id,stus[i].sum);
return 0;
}