#include "iostream"
#include "string.h"
#include "iostream"
#include "fstream"
#include <vector>
#include <algorithm>
using namespace std;
char ch[100];
struct msd //marksixdata
{
int year;
int term;
int n_norm[6];
int n_special;
};
vector<msd> vec_msd;
msd msd_temp;
//void seperate(char* pch_data)
void GetData(string str_data)
{
//cout<<str_data.c_str()<<endl;
string str_data_temp;
int n_EndPos = 0;
int n_BeginPos = 0;
/*----------------------------------------------------------------------------------------------*/
n_EndPos = str_data.find_first_of(' ', n_BeginPos);
// cout << n_EndPos <<endl;
str_data_temp.assign(str_data, n_BeginPos, n_EndPos-n_BeginPos);
// cout << str_data_temp.c_str() << endl;
msd_temp.year = atoi(str_data_temp.c_str());
//Extract year
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*----------------------------------------------------------------------------------------------*/
n_BeginPos = str_data.find_first_not_of(' ', n_EndPos);
n_EndPos = str_data.find_first_of(' ', n_BeginPos);
str_data_temp.assign(str_data, n_BeginPos, n_EndPos-n_BeginPos);
// cout << str_data_temp.c_str() << endl;
msd_temp.term = atoi(str_data_temp.c_str());
//
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*----------------------------------------------------------------------------------------------*/
n_BeginPos = str_data.find_first_not_of(' ', n_EndPos);
n_EndPos = str_data.find_first_of(' ', n_BeginPos);
str_data_temp.assign(str_data, n_BeginPos, n_EndPos-n_BeginPos);
// cout << str_data_temp.c_str() << endl;
msd_temp.n_norm[0] = atoi(str_data_temp.c_str());
//
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*----------------------------------------------------------------------------------------------*/
n_BeginPos = str_data.find_first_not_of(' ', n_EndPos);
n_EndPos = str_data.find_first_of(' ', n_BeginPos);
str_data_temp.assign(str_data, n_BeginPos, n_EndPos-n_BeginPos);
// cout << str_data_temp.c_str() << endl;
msd_temp.n_norm[1] = atoi(str_data_temp.c_str());
//
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*----------------------------------------------------------------------------------------------*/
n_BeginPos = str_data.find_first_not_of(' ', n_EndPos);
n_EndPos = str_data.find_first_of(' ', n_BeginPos);
str_data_temp.assign(str_data, n_BeginPos, n_EndPos-n_BeginPos);
// cout << str_data_temp.c_str() << endl;
msd_temp.n_norm[2] = atoi(str_data_temp.c_str());
//
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*----------------------------------------------------------------------------------------------*/
n_BeginPos = str_data.find_first_not_of(' ', n_EndPos);
n_EndPos = str_data.find_first_of(' ', n_BeginPos);
str_data_temp.assign(str_data, n_BeginPos, n_EndPos-n_BeginPos);
// cout << str_data_temp.c_str() << endl;
msd_temp.n_norm[3] = atoi(str_data_temp.c_str());
//
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*----------------------------------------------------------------------------------------------*/
n_BeginPos = str_data.find_first_not_of(' ', n_EndPos);
n_EndPos = str_data.find_first_of(' ', n_BeginPos);
str_data_temp.assign(str_data, n_BeginPos, n_EndPos-n_BeginPos);
// cout << str_data_temp.c_str() << endl;
msd_temp.n_norm[4] = atoi(str_data_temp.c_str());
//
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*----------------------------------------------------------------------------------------------*/
n_BeginPos = str_data.find_first_not_of(' ', n_EndPos);
n_EndPos = str_data.find_first_of(' ', n_BeginPos);
str_data_temp.assign(str_data, n_BeginPos, n_EndPos-n_BeginPos);
// cout << str_data_temp.c_str() << endl;
msd_temp.n_norm[5] = atoi(str_data_temp.c_str());
//
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*----------------------------------------------------------------------------------------------*/
n_BeginPos = str_data.find_first_not_of(' ', n_EndPos);
n_EndPos = str_data.find_first_of(' ', n_BeginPos);
str_data_temp.assign(str_data, n_BeginPos, n_EndPos-n_BeginPos);
// cout << str_data_temp.c_str() << endl;
msd_temp.n_special = atoi(str_data_temp.c_str());
//
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
vec_msd.push_back(msd_temp);
}
int main()
{
ifstream in("test.txt");
// vec_msd.clear();
while(in.getline(ch, 100))
{
GetData(ch);
}
int i_vec_size;
i_vec_size = vec_msd.size();
cout << "总共期数:" << i_vec_size << endl;
int n_0_9_array[10] = {0};
int n_0_9_array_MaxNotCome[10] = {0};
struct max_no_come
{
int year;
int term;
int number;
int times;
}max_no_come;
max_no_come.number = 0;
max_no_come.times = 0;
max_no_come.year = 0;
max_no_come.term = 0;
int j = 0;
int k = 0;
int i_index;
for(j=0; j<i_vec_size; j++)
{
// cout << vec_msd[j].year <<' ' <<vec_msd[j].term << " "<< vec_msd[j].n_norm[0]<< " "<< vec_msd[j].n_norm[1]<< " "<< vec_msd[j].n_norm[2] << " "<< vec_msd[j].n_norm[3] << " "<< vec_msd[j].n_norm[4] << " "<< vec_msd[j].n_norm[5] << " "<< vec_msd[j].n_special <<endl;
for (k=0; k<10; k++)
{
++n_0_9_array_MaxNotCome[k];
}
for(k=0; k<6; k++)
{
i_index = vec_msd[j].n_norm[k]%10;
++n_0_9_array[i_index];
n_0_9_array_MaxNotCome[i_index] = 0;
}
i_index = vec_msd[j].n_special%10;
++n_0_9_array[i_index];
n_0_9_array_MaxNotCome[i_index] = 0;
for (k=0; k<10; k++)
{
if (n_0_9_array_MaxNotCome[k] > max_no_come.times)
{
max_no_come.times = n_0_9_array_MaxNotCome[k];
max_no_come.number = k;/
max_no_come.year = vec_msd[j].year;
max_no_come.term = vec_msd[j].term;
}
}
} //end of calculate
for(k=0; k<10; k++)
{
cout << "数尾为" << k << "的号码来了:" << n_0_9_array[k] << "次。" <<endl;
}
cout << "数尾为:" << max_no_come.number<<"的号码最多"<< max_no_come.times<<"期没来,发生在"<<max_no_come.year<<"年第"<<max_no_come.term<<"期"<<endl;
return 0;
}