随机时间.排序,分出时 分 秒
srand((unsigned)time(NULL));std::vector<int> hour;//时 std::vector<int> minute;//分 std::vector<int> second;//秒 std::vector<int> vSecond;//总秒数int n = 5000;//随机个数for (int i = 0; i < n; i++) { int _second = rand() % 18000; vSecond.push_back(_second);}for(int i =0 ; i< n-1; ++i) { for(int j = 0; j < n-i-1; ++j){if(vSecond[j] < vSecond[j+1]) {int tmp = vSecond[j] ; vSecond[j] = vSecond[j+1] ; vSecond[j+1] = tmp; } } }for (int i = 0; i < n; i++){ hour.push_back(vSecond[i] / 3600);minute.push_back(vSecond[i] / 60 % 60); second.push_back(vSecond[i] % 60); } FILE *f;f = fopen("Time.csv" , "wb");for (int i =0; i< n; i++) { fprintf(f,"%d, %d, %d\n", hour[i], minute[i], second[i]);}fclose(f);
posted @ 2016-03-11 11:12 HaoK 阅读( ...) 评论( ...) 编辑 收藏