1148:0 start-up algorithm 55--print all points below average time limit:1 Sec Memory limit:64 MB 64bit IO Format:%lld
submitted:2456 accepted:777
[Submit] [Status] [Web Board] Description
Enter n scores to print out all points below the average score (Note: Ave = S/n is float or ave = (float) n/a).
Input
Multiple test data
Each test data row, in this line first enter the number of fractions N (1<=n<=100), and then followed by the input n integers (representing fractions)
Output
For each test data, the output line outputs all points below the (<) average score in the input order, separated by a space, and if there is no lower than average, only one blank line is output
Sample Input
3 40 50 602 90 804 10 10 90 80
Sample Output
408010 10
Source
0 Starting point Learning algorithm
1#include <stdio.h>2 intMain () {3 intn,a[ $],b[ $];4 while(SCANF ("%d", &n)! =EOF) {5 ints=0;6 for(intI=0; i<n;i++){7scanf"%d",&a[i]);8s+=A[i];9 }Ten floatAve= (float) s/N; One intj=0; A for(intI=0; i<n;i++){ - if(a[i]<Ave) { -b[j]=A[i]; theJ + +; - } - } - if(j==0) +printf"\ n"); - Else{ + for(intI=0; i<j-1; i++){ Aprintf"%d", B[i]); at } -printf"%d\n", b[j-1]); - } - } - return 0; -}
1148:0 start-up algorithm 55--print all points below the average score