www.zhnq.net > 计算平均分并输出

计算平均分并输出

#include<stdio.h> void main() { int sum=0; int n=0; int a,i; do{ printf("请输入成bai绩,以du-1结束:"); scanf("%d",&a); while(a>100) { printf("输入错误zhi,请重新输入:"); scanf("%d",&a); } sum+=a;//求总分dao n++;//统计专人数 }while(a!属=-1) printf("平均分为:%d\n",sum/n); }

#include #define N 10 int main(void) { double score[N]; double average, sum = 0.0; int i; //输入学生成绩 for (i = 0; i

试一下以下代码#include #include struct student{ char sex; char name[8]; char sno[20]; int age; double score;};int main(){ FILE *fp; double avg,sum=0; int i; struct student Student[5]; //fp=fopen("D:\\CC\\data2.txt","w"); fp=fopen("data2.txt","w

#include <stdio.h>#define LEN 100int main (void){float total = 0.0;float score ;int i = 0;while (i++< 100 && scanf ("%f", &score) == 1){ total += score;}printf ("%f\n", total / 100.0);return 0;} 晕,不是很难的问题,自己动动 脑,脑袋不是拿来好看的哈

#include<stdio.h> void main () { float m=0.0,p,sum=0.0;int i; for(i=1;i<6;i++) { printf("输入第%d个学生的成绩如下:",i); scanf("%f",&p); sum+=p; } m=sum/5; printf("平均分为%f\n",m); } 已经运行过,可以运行成功

Private Sub Command1_Click() Dim n As Integer Dim show As String Dim a() n = CInt(InputBox("输入学生数")) ReDim a(n) For i = 1 To n a(n) = CInt(InputBox("请输入第 " & CStr(i) & " 名学生成绩")) average = average + a(n) Next i

设置两个变量如max=-1和min=9999和一个count=0,将某门课程的各个分数放在一个数组中,然后从1个分数开始向后循环和max和min比较,比min小就让min等于那个分数,比max大就让max等于那个分数,在把总分用count量累加起来,最后输出count/n(平均分,n为分数个数)、max(最高分)、min(最低分).

//虽然,我知道上面的大哥写的很好,但是好象功能太强了//简单写了一个,觉得发上来玩玩/* 编写一个程序,输入N个学生数据,包括学号、姓名和三门功课的成绩, 要求计算平均分并输出这些学生的数据.*/#include <iostream> using

代码如下:public class Weimo{ public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double[] score = new double[10]; int sum = 0; for (int i = 0; i < score.length; i++) { System.out.println("请输入第" + (i+1) + "个

#include void main() { int n,i=0; float sum=0,average; printf("输入学生的数目:"); while(n20) scanf("%d",&n); float str[30]; while(i { scanf("%f",&str[i]); i++; } for(int i=0;i sum+=str[i]; average=sum/n; printf("平均成绩为:%.2f\n",average); printf("高出平均的成绩:"); i=0; while(i { if(str[i]>average) printf("%.2f ",str[i]); i++; } }

网站地图

All rights reserved Powered by www.zhnq.net

copyright ©right 2010-2021。
www.zhnq.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com