#include stdio.h
創(chuàng)新互聯(lián)長期為上千家客戶提供的網(wǎng)站建設服務,團隊從業(yè)經(jīng)驗10年,關注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務;打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為囊謙企業(yè)提供專業(yè)的網(wǎng)站設計制作、成都網(wǎng)站建設,囊謙網(wǎng)站改版等技術服務。擁有十多年豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。
#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; n121; n++)
{
suanzi[n]=(int)(rand()*255);
}
for(n=0; n121; n++)
{
words[n]^=suanzi[n];
}
words[120]='\0';
printf("%s",words);
getch();
return 0;
}
#includestdio.h
#define?N?7
#define?M?10
struct?Sing
{
char?name[20];
int?score[10];
float?aver;
}sing[10];
void?mywrite()
{
int?i=0,j=0,max=0,min,sum;
for(i=0;iM;i++)
{???min=0;
max=0;
sum=0;
printf("請輸入第%d個選手的姓名\n",i+1);
scanf("%s",sing[i].name);
printf("請依次輸入成績:\n");
scanf("%d",sing[i].score[0]);
min=sing[i].score[0];
sum=min;
for(j=1;jN;j++)
{???
scanf("%d",sing[i].score[j]);
sum=sum+sing[i].score[j];
if(maxsing[i].score[j])
{
max=sing[i].score[j];
}
if(minsing[i].score[j])
min=sing[i].score[j];
}
sing[i].aver=(sum-max-min)/5.0;
}
}
void?sort()
{
int?i,j;
struct?Sing?s;
for(i=0;iM;i++)
for(j=0;jM-1-i;j++)
{
if(sing[j].aversing[j+1].aver)
{
s=sing[j];
sing[j]=sing[j+1];
sing[j+1]=s;
}
}
}
int?main()
{
mywrite();
sort();
for(int?i=0;iM;i++)
{
printf("%-15s%f\n",sing[i].name,sing[i].aver);
}
return?0;
}
代碼文本:
#include "stdio.h"
double tol_ave(int a[],int n,int *s){
int i;
for(*s=0,i=0;in;*s+=a[i++]);
return *s/(n+0.0);
}
void level(int a[],int n){
int v,g,m,p,f;
for(v=g=m=p=f=0,n--;n=0;n--){
v += a[n]=90;
g += a[n]=80 a[n]90;
m += a[n]=70 a[n]80;
p += a[n]=60 a[n]70;
f += a[n]60;
}
printf("優(yōu)秀\t良好\t中等\t及格\t不及格\n");
printf("======================================\n");
printf(" %d\t %d\t %d\t %d\t %d\n",v,g,m,p,f);
}
int main(int argc,char *argv[]){
int sum,a[1000],i,n;
double ave;
printf("輸入學生人數(shù):");
if(scanf("%d",n)!=1 || n1 || n1000){
printf("Input error, exit...\n");
return 0;
}
printf("請輸入%d個學生的成績...\n",n);
for(i=0;in;scanf("%d",a+i++));//輸入成績
ave=tol_ave(a,n,sum);
printf("\n總? 分:? %d\t平均分:? %.2f\n",sum,ave);
printf("\n等級分布如下:\n");
level(a,n);
putchar('\n');
return 0;
}
代碼如下:
#include stdio.h
//判斷及格人數(shù)
int fun(int a[10]){
int i, count=0;
for (i = 0; i 10; ++i)
if(a[i]=60) count++;? ? ? ? ?
return count;
}? ? ?
int main(){
int a[10],i;
printf("請輸入10名學生的成績:\n");
for(i = 0;i 10; i++)
scanf("%d",a[i]);? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
int count = fun(a);
printf("及格的人數(shù)為:%d\n", count);? ? ? ?
return 0;
}? ? ?
程序運行結(jié)果:
擴展資料
C語言中對數(shù)字的統(tǒng)計:可以通過循環(huán)數(shù)組的方式去一個一個的比較數(shù)字的大小,然后進行統(tǒng)計。首先可以通過循環(huán)的方式讀取每個數(shù)字,然后存到數(shù)組中。把數(shù)組傳入到fun函數(shù),在循環(huán)數(shù)組對每個數(shù)字進行比較統(tǒng)計。