demo
1 #include <iostream> 2 #include <fstream> 3 #define NUMOFDATAS 25000000 4 5 using namespace std; 6 double array[NUMOFDATAS]; 7 int main(int argc, char const* argv[]) 8 { 9 freopen("50ETF.txt","rb",stdin); 10 11 double data; 12 int cnt = 0; 13 while(scanf("%lf",&data) != EOF) { 14 array[cnt++] = data; 15 } 16 17 double max = 0; 18 for(int i = 0; i < cnt; i++) { //find the max number 19 if(max < array[i]) { 20 max = array[i]; 21 } 22 } 23 cout<<"the max number is "<<max<<endl; 24 25 int pre_num = 0,now_num = 0; 26 for(int i = 1; i <= 10; i++) { 27 double temp = (i*0.1)*max; 28 now_num = 0; 29 for(int j = 0; j < cnt; j++) { 30 if(temp > array[j]){ 31 now_num++; 32 } 33 } 34 int ans = now_num - pre_num; 35 cout<<"the number of \%"<<(i-1)*10<<"- \%"<<i*10<<" is "<<ans<<endl; 36 pre_num = now_num; 37 } 38 return 0; 39 }
Do one thing , and do it well !