数组
1.
#include<stdio.h>
int main(){
int a ;
int d;
scanf("%d",&a);
if(a>=90&&a<=100){
d=1;
}else if(a>=80&&a<=89){
d=2;
}else if(a>=70&&a<=79){
d=3;
}else if(a>=60&&a<=69){
d=4;
}else if(a<60){
d=5;
}
switch(d){
case 1:printf("A");break;
case 2:printf("B");break;
case 3:printf("C");break;
case 4:printf("D");break;
case 5:printf("不及格");break;
}
}
2.
#include<stdio.h>
int main(){
int i;
float s=0;
float max=0;
float b[10];
for(i=0;i<10;i++){
scanf("%f",&b[i]);
s=s+b[i];
if(max<b[i]){
max=b[i];
}
}
printf("数组的和:%f\n",s);
printf("数组的平均值:%f\n",s/10);
printf("数组的最大值:%f",max);
}
3.
#include<stdio.h>
int main(){
int i;
int a[]={8,5,6,7,1,2,3,4};
int b[8]={};
for(i=7;i>=0;i--){
b[7-i]=a[i];
printf("%d,",b[7-i]);
}
}
网友评论