Xubx


私信TA

用户名:dotcpp0643823

访问量:1681

签 名:

种瓜得瓜,种豆得豆

等  级
排  名 15390
经  验 792
参赛次数 0
文章发表 7
年  龄 18
在职情况 学生
学  校 哈尔滨师范大学
专  业

  自我简介:

TA的其他文章

简单数学题
浏览:136

解题思路:
通过for循环遍历所有数求出最大与最小值。
注意事项:

参考代码:

#include<stdio.h>
#include<math.h>
int main(){
   int n;
   double sum=0;//总数
   scanf("%d",&n);
   int a[n];
   for(int i=0;i<n;i++){
       scanf("%d",&a[i]);
       sum+=a[i];
   }
   int t=a[0];//最大
   int u=a[0];//最小
   double num;//平均数
   for(int i=1;i<n;i++){
       if(a[i]>t){
           int temp;
           temp=a[i];
           a[i]=t;
           t=temp;
       }
       if(a[i]<u){
           int temq;
           temq=a[i];
           a[i]=u;
           u=temq;
       }
   }
   num=(sum*1.0)/n;
   printf("%d\n",t);
   printf("%d\n",u);
   printf("%.2lf",num);
}

 

0.0分

2 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区