#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;
}
分享到:
相关推荐
marksix java console application
标题“stat6.zip_marksix_marksix六”暗示了这是一个关于分析“marksix六”数据的统计项目,其中可能包含了对1到49个数字的频数分布研究。描述中的“stat the 1-49 of marksix by using frequency distribution”...
"markSix" 是一个与 neog.Camp 项目相关的代码分配,它是一个基于 Vanilla JS(纯JavaScript)开发的语言翻译工具。"Vanilla JS" 是指不依赖任何框架或库的原生JavaScript,它允许开发者充分利用JavaScript的核心...
"MarkSix-SpiralChart" 是一个项目,很可能与数据可视化和编程有关,特别是使用 PowerShell 这种强大的脚本语言来创建螺旋图表。PowerShell 是微软开发的一种命令行工具,常用于系统管理任务,但也可以用于创建图形...
Mark Six Analyst是香港彩票或所谓Mark 6的数据库。 它提供了各种统计方法的工具来显示数据和预测之间的关系。
采用分层架构、插件机制、模板引擎驱动开发模式,能打字就能排版,支持简版,触摸板,电脑版三种页面。 Sql Server数据库(暂时只有SQL Server数据库,以后将支持MYSQL,ACCESS等数据库),部分功能正在开发中......