1 like 0 dislike
9.9k views
請設計一程式,由使用者輸入N個數字,求這些數字的平均。使用者輸入的第一個數字N代表接下來會有多少個數字要求平均,接下來的N個數字就是需要計算平均的數。輸出請輸出到小數點後六位。

sample input:

10 1 2 3 4 5 6 7 8 9 10

sample output:

5.500000
[Exercise] Coding (C) - asked in 2016-1 程式設計(一)AC by (18k points)
ID: 15378 - Available when: 2016-10-27 18:30:00 - Due to: 2016-10-27 21:00:00

edited by | 9.9k views
0 1
Called for Help
0 0
#include <stdio.h>
#include <stdlib.h>

int main()

{
    int a,n;
    float c;
    scanf("%d",&a);
    int b[a];
    for(n=0;n<a;n++)
    {
        scanf("%d",&b[n]);
    }
    for(n=0;n<a;n++)
    {
        c=c+b[n];
    }
    printf("%.6f",c/a);
    return 0;
}

102 Answers

0 like 0 dislike
Hidden content!
** * **** ** **



int main()



{
** ***** * * * * ** * * *** = 0, j = 0;
** * **** * * *** **** * = 0,box = 0;




* * * *** ** *** ** *** *** ** ** *** *


**** * * * ** * * * * * *


* **** ** * * * ** *** = 0;j * * i;j ++)
** ** ***** ***** ** ** **** * * ** **






** ** * * *** ** * *** = 0;j * * i;j ++)
* *** *** ** **** = box + ** *


* * ** ** * *** * * * = box / i;


*** * * ***** *** *** ** ******* *






*** * 0;





}
answered by (-122 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>

int main()





{
* ** *** * * * ** * ** ** a;

    int i,b[100];
** *** * *** ** ** * *** * * *** * * * ** **** *** ** * * * ***


* ****** ** * * * * * *** ***** ***** * * * (i=1;i<=a;i++)
**** *** *** * ***** * * * ** * *** ** ** ***
****** * *** * *** *** * **** ** * * * ** * * * * * * * * * **** *** * **


* **** ** ** ** * * ** *** * * * * * *


* * **** * ** * * ** ** ** *** ***** * * ** * * * * **


* ** * *** ***** * 0;

}
answered by (-85 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

int main()

{
** * * ** *** * n= 0 ,i= 0 ,j= 0 ,num[n];
*** **** *** * ** ** ** * a;
* * * *** * * ** ** ******* *** * * * ***
* ** ****** * ** * ***
* * * * 0 ;n<i;n++)

    {
**** ** ** * **** * * *** * ****** *** *** * ******* ** ** * * **
* * ***** * *** * ** *** *** *** * *** ** * ****
* ***** * * ** **
* ** **** **** *** ***
** ** * ** * * * *** * *** * *** ******
** * * ** * **** * ***** * 0;

}
answered by (-103 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

int main()

{
** *** * ** * * ***** n= 0 ,i= 0 ,j= 0 ,num[n];
* *** * **** ** * ** a;
* * * * * ** ** * ** * ** ** **
* * * **** ** *** *
* * ** * *** ** * * * 0 ;n<i;n++)

    {
** * ** * ** * * *** ** **** * * * * **** *** * * * * *** **
** * *** ** * * **** *** * * ** ** *** ** * * *
** *** * * ** *
*** * * * * ** **** ***
** * ** ** *** *** **** ****** ** *** *** ***
****** * * **** ** ** * 0;

}
answered by (-103 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>





main()

{
** * * ** * ** *** ** * i,a,tmp;
* * * * * *** ** ** * * sum=0;
* * * * ********* * * * **** * b=0;
* *** * *** ** * * **** * num[10]={0};
** ** ** * * * * * ** * * ** ** ** * * *
*** ** ** ** *** ** * * * (i=0;i<a;i++)
* * ** * **** * * ** *** ** * *** * ** * * * * ** ****** *
* * * ** * * ** * * * *** * ** **** ****** ****** ** * ** * *


* ** * * * * * * *** = sum / a;


* **** * * * * ** * * ****** * * * *










* * ***** * * ** * ** 0;

}




* ** ** *** ** ** ** *** 0;

}
answered by (-158 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>





main()

{
* * * *** * * ** * i,a,tmp;
** * * * * * ** *** sum=0;
* *** * * *** * * * b=0;
* * **** ** * * * * * num[10]={0};
** *** * * * * * * * * * * ** **** * ******
*** * * ********* (i=0;i<a;i++)
*** * ***** ** ***** * **** ****** * * * * * ** * * *** * ** ** ***** **
*** ** *** ** *** * ** * * **** * * * *** *** * ** **** * *** *** *
** * * *** * * * *****
* ***** * ** * * ** * = sum / tmp;


**** * *** ** ***** *** ** * ** * * * *** *










* ** ** * *** * ** **** ** * 0;

}
answered by (-158 points)
0 like 0 dislike
Hidden content!
#include ** * ** *

int main()

{
****** ** * ** i ,n ;
* ** * ***** * * * ** ** * * ** *** ;


** ** ** *** * stu[n] ;
** * * * ****** * * sum=0 ,c=0;
** * * * ** *** * * ;i<n ; i++)
** ***** ** * ***
** * ** ** * ** * * ** **** *** * * **** ** * * *** * ,&stu[i]);
*** * ** ** * ** *** ** **** * * * += stu[i] ;


**** *** * *


* * * * * *** * ** **** ,sum/n) ;




* ** * * 0 ;

}
answered by (-88 points)
0 like 0 dislike
Hidden content!
** * * * ** *** ***



int main()



{
** ** * *** * * ** * = 0, j = 0, box = 0;
* * * *** * * ** * = 0;




* ** **** * * ** *** * ****** **** * * * * ***


* * ****** ** * ** **** **


* * * ** * ** * ** = 0;j * ** i;j ++)
* * ** * * * * * * *** *** * * **






*** **** * * * * * * * = 0;j ** i;j ++)
* ** ** ** * ** * *** = box + * *** *


* * ** **** **** = box / i;


** *** * ******* ** * * ** * **




* ** *** * * * ****** 0;







}
answered by (-122 points)
0 like 0 dislike
Hidden content!
***** * ** * ** ***



int main()



{
*** * * * ** * = 0, j = 0, box = 0;
* * * ** * * ** ** * * * * = 0;




** * * ***** ** * ** * ** * * **


* *** * ** * * *


**** * ****** * * ** = 0;j ** i;j ++)
** **** ** ** * *** ** * * *** * **






* **** * ** *** *** = 0;j **** i;j ++)
* *** *** * ***** = box + * * *


* *** ** * ** * *** = box / i;


** * * * **** * *** * * **** *




*** ** * * * ** * * *** 0;







}
answered by (-122 points)
0 like 0 dislike
Hidden content!
** * * * * * ** * *



main()



{
** ** *** * * ** ** * = 0, j = 0, box = 0;
** ** ***** * * **** * = 0;




* ** * ** * *** * * * * * ** * * * * *


**** *** ** * * * * ** *


** * *** ***** ** * * = 0;j ** *** i;j ++)
* * * * ** ** ***** **** * * * *






* *** *** ** *** ** = 0;j < i;j ++)
** *** ** ** * * ** = box + * ** ***


** * * * *** * = box / i;


* ** ******** ** * * *** *** ** ** *




****** ** * ** * ** * * 0;







}
answered by (-122 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.214.204
©2016-2025

Related questions

0 like 0 dislike
0 answers
[Resource] asked Oct 27, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 15475 - Available when: Unlimited - Due to: Unlimited
| 13 views
0 like 0 dislike
5 answers
[Exercise] Coding (C) - asked Oct 27, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 15447 - Available when: 2016-10-27 18:30:00 - Due to: 2016-10-27 21:00:00
| 1.3k views
1 like 0 dislike
37 answers
[Exercise] Coding (C) - asked Oct 27, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 15446 - Available when: 2016-10-27 18:30:00 - Due to: 2016-10-27 21:00:00
| 4.3k views
1 like 0 dislike
17 answers
[Exercise] Coding (C) - asked Oct 27, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 15442 - Available when: 2016-10-27 18:30:00 - Due to: 2016-10-27 21:00:00
| 2.3k views
1 like 0 dislike
18 answers
[Exercise] Coding (C) - asked Oct 27, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 15440 - Available when: 2016-10-27 18:30:00 - Due to: 2016-10-27 21:00:00
| 2.2k views
12,783 questions
183,442 answers
172,219 comments
4,824 users