Article Directory
1. Multiple choice questions
1-5 BBADC
6-10 BDBCC
11-15 DDDDC
16-20 BAACD
Two, programming questions
- Input 10 integers from the keyboard into the array, find the number and average of the positive numbers, and output the result (the average is accurate to two decimal places)
#include<stdio.h>
int main()
{
int a[10],sum=0,count=0;
float avg=0.00;
for(int i=0;i<10;i++){
scanf("%d",&a[i]);
if(a[i]>0){
sum=sum+a[i];
count++;
}
}
avg=(float)sum/count;
printf("正数个数%d\n",count);
printf("平均值:%0.2f\n",avg);
return 0;
}
- Input several student scores from the keyboard. When entering a negative number, the input is over, and the average score and the student scores below the average score are output (the average is accurate to two decimal places)
#include<stdio.h>
int main()
{
int i=0,j=0;
float a[10000];
float avg=0.00,sum=0.00;
float b[10000];
int x=0,len;
for(i=0;;i++){
scanf("%f",&a[i]);
if(a[i]<0){
break;
}
sum=sum+a[i];
j++;
}
avg=sum/j;
printf("平均成绩:%0.2f\n",avg);
for(i=0;i<j;i++){
if(a[i]<avg){
b[x]=a[i];
printf("比平均值小的成绩: %0.2f\n",b[x]);
x++;
}
}
}
- The following programming questions will be issued separately
If you have any questions, you can leave a message in the comment area