哈哈哈哈我是哇哈哈
2020-03-05 10:43
#include <stdio.h>
int main()
{
int score[10]={67,98,75,63,82,79,81,91,66,84};
int a,b,c,d,sum=0;
int i,j,k,l,m,n;
for(i=0;i<10;i++)
{
sum=sum+score[i];
}
printf("学生的总分是%d\n",sum);
for(j=1;j<10;j++)
{
if(score[j-1]<score[j])
{
a=score[j];
score[j]=score[j-1];
score[j-1]=a;
}
}
printf("学生的最高分是%d\n",score[0]);
printf("学生的最低分是%d\n",score[9]);
printf("学生的平均分是%d\n",sum/10);
printf("以下是学生成绩降序排序:\n");
for(k=0;k<10;k++)
{
printf("%d ",score[k]);
}
return 0;
}
#include <stdio.h> void Sum(int arr[],int len){ int sum = 0; for(int i = 0;i<len;i++){ sum += arr[i]; } printf("总分为%d\n",sum); } void maxScore(int arr[],int len){ int i; int max = arr[0]; for(i=1;i<len;i++){ if(arr[i] > max){ max = arr[i]; } } printf("最高分为%d\n",max); } void minScore(int arr[],int len){ int i; int min = arr[0]; for(i=1;i<len;i++){ if(arr[i] < min){ min = arr[i]; } } printf("最低分为%d\n",min); }void Average(int arr[],int len){ float average; int sum = 0; for(int i = 0;i<len;i++){ sum += arr[i]; } average = sum/(len); printf("平均分为%f\n",average); }void Sort(int arr[],int len){ int tem; printf("********排序前*********\n"); for(int i = 0;i<len;i++){ printf("%d\t",arr[i]); } printf("\n"); for(int i = len-1;i>0;i--){ for(int j = 0; j<i;j++){ if(arr[j]<arr[j+1]){ int tem; tem = arr[j]; arr[j] = arr[j+1]; arr[j+1] = tem; } } } printf("********排序后*********\n"); for(int i = 0;i<len;i++){ printf("%d\t",arr[i]); } } int main(){ int score[]={67,98,75,63,82,79,81,91,66,84}; int len = sizeof(score)/sizeof(score[0]); // printf("%d\n",len); Sum(score,len);//总分为786 maxScore(score,len);//最高分为98 minScore(score,len);//最低分为63 Average(score,len);//平均分为78.000000 Sort(score,len); return 0; }
#include <stdio.h>
#define N 10
void totalScore(int a[]){
int i,sum = 0;
for(i = 0; i <N; i++){
sum += a[i];
}
printf("考试成绩总分为%d\n",sum);
}
void maxMinScore(int b[],int c){
int i,max = b[0],min = b[0];
for(i = 0;i < N;i++){
if(b[i] >= max && c == 1){
max = b[i];
}else if(b[i] <= min){
min = b[i];
}
}
if(c == 1){
printf("考试成绩最高分为%d\n",max);
}else{
printf("考试成绩最低分为%d\n",min);
}
}
void average(int d[]){
int i,ave,sum=0;
for(i = 0; i < N;i++){
sum+=d[i];
}
ave = sum/(i+1);
printf("考试成绩平均分为%d\n",ave);
}
void desOrder(int d[]){
int i,j,temp;
for(i=0;i<N;i++){
for(j=0;j<N;j++){
if(d[i] > d[j]){
temp = d[j];
d[j] = d[i];
d[i] = temp;
}
}
}
for(i = 0; i < N;i++){
printf("%d ",d[i]);
}
}
int main()
{
int score[N]={67,98,75,63,82,79,81,91,66,84};
totalScore(score);
maxMinScore(score,1);
maxMinScore(score,0);
average(score);
printf("考试成绩降序排列:\n");
desOrder(score);
return 0;
}
C语言入门
926212 学习 · 20797 问题
相似问题