首页 > 其他 > 详细

demo

时间:2016-04-24 06:18:53      阅读:220      评论:0      收藏:0      [点我收藏+]
 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 }

 

demo

原文:http://www.cnblogs.com/ubuntu-kevin/p/5426212.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!