當前位置:首頁 » 編程軟體 » 編程求30

編程求30

發布時間: 2024-07-15 12:34:53

A. c語言編程 題目:輸入30個學生成績,求最高分,最低分和平均分(用數組存放數據)

#include<stdio。h>

intmain()

{

intmax,min,score;

doubleavg=0;

scanf("%d",&score);

max=min=score;

avg+=score;

for(inti=0;i<29;i++)

{

scanf("%d",&score);

if(score>max)max=score;

if(score<min)min=score;

avg+=score;

}

avg=avg/30;

printf("最高分max=%d,最低分min=%d,平均分avg=%lf ",max,min,avg);

return0;

}

文件輸入/輸出

在C語言中,輸入和輸出是經由標准庫中的一組函數來實現的。在ANSI C中,這些函數被定義在頭文件;中。

標准輸入/輸出

有三個標准輸入/輸出是標准I/O庫預先定義的:

stdin標准輸入

stdout標准輸出

stderr輸入輸出錯誤

以上內容參考:網路-c語言

B. c++編程 從鍵盤上輸入30個學生的分數,求最大值,最小值,平均分,以及大於90分的人數和低於60分的人數…

#include"iostream"

usingnamespacestd;

intmain()

{

intnum[30],max=0,min=101,total=0,temp;

inti,j;

for(i=0;i<30;i++)

{

cout<<"輸入第"<<i+1<<"個分數:";

cin>>num[i];

if(num[i]>max)max=num[i];

if(num[i]<min)min=num[i];

total=total+num[i];

}

cout<<"最大分數為:"<<max<<endl;

cout<<"最小分數為:"<<min<<endl;

cout<<"平均分數為:"<<total/30<<endl;

cout<<"大於90分的:";

for(i=0;i<30;i++)

if(num[i]>90)cout<<num[i]<<"";

cout<<endl<<"小於60分的:";

for(i=0;i<30;i++)

if(num[i]<60)cout<<num[i]<<"";

cout<<endl;

return0;

}

(2)編程求30擴展閱讀

輸入10個同學的成績,統計80分以上和不及格的人數,並輸出平均值

#include<iostream>

usingnamespacestd;

intmain()

{

doublea[10],sum=0,var;

inti,j=0,k=0;

cout<<"請輸入10個學生成績:"<<endl;

for(i=0;i<10;i++)

{

cin>>a[i];

sum=sum+a[i];

if(a[i]>=80)

j++;

if(a[i]<60)

k++;

}

var=sum/10;

cout<<"80分以上的人數是:"<<j<<endl;

cout<<"不及格的人數是:"<<k<<endl;

cout<<"平均分是:"<<var<<endl;

return0;

}

熱點內容
ios應用上傳 發布:2024-09-08 09:39:41 瀏覽:438
ios儲存密碼哪裡看 發布:2024-09-08 09:30:02 瀏覽:870
opensslcmake編譯 發布:2024-09-08 09:08:48 瀏覽:653
linux下ntp伺服器搭建 發布:2024-09-08 08:26:46 瀏覽:744
db2新建資料庫 發布:2024-09-08 08:10:19 瀏覽:173
頻率計源碼 發布:2024-09-08 07:40:26 瀏覽:780
奧迪a6哪個配置帶後排加熱 發布:2024-09-08 07:06:32 瀏覽:101
linux修改apache埠 發布:2024-09-08 07:05:49 瀏覽:209
有多少個不同的密碼子 發布:2024-09-08 07:00:46 瀏覽:566
linux搭建mysql伺服器配置 發布:2024-09-08 06:50:02 瀏覽:995