//
// main.c
// Test
//
// Created by 吕颖 on 2019/1/16.
// Copyright © 2019年 carmen. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int getAction(int num);
int main(int argc, const char * argv[]) {
int number = 0;
int actionNum = 0;
int acount[20] = {0};
srand((unsigned)time(NULL));
for (int i=0; i<10000; i++){
number = rand()%10000;
actionNum = getAction(number);
acount[actionNum]++;
}
for(int i=0; i<20; i++){
printf("%d出现%d次\n", i+1, acount[i]);
}
return 0;
}
int getAction(int num){
int ret = 0;
int account[20] = {1433,2399,2533,3211,3333,
3644,3934,4444,4812,5555,
5733,6233,6666,6912,7342,
7777,8201,8888,9219,9999};
for(int i = 0; i < 20; i++){
if(num < account[i]){
ret = i+1;
break;
}
}
return ret;
// int ret = 0;
// if(num < 1423){
// ret = 1;
// } else if(num < 2399){
// ret = 2;
// } else if(num < 2512){
// ret = 3;
// } else if(num < 2784){
// ret = 4;
// } else if(num < 3212){
// ret = 5;
// } else if(num < 3721){
// ret = 6;
// } else if(num < 4012){
// ret = 7;
// } else if(num < 4609){
// ret = 8;
// } else if(num < 5022){
// ret = 9;
// } else if(num < 5412){
// ret = 10;
// } else if(num < 5876){
// ret = 11;
// } else if(num < 6322){
// ret = 12;
// } else if(num < 6541){
// ret = 13;
// } else if(num < 6987){
// ret = 14;
// } else if(num < 7433){
// ret = 15;
// } else if(num < 7845){
// ret = 16;
// } else if(num < 8325){
// ret = 17;
// } else if(num < 8743){
// ret = 18;
// } else if(num < 9509){
// ret = 19;
// } else {
// ret = 0;
// }
// return ret;
}