Demo entry 6754797

吴熙炜

   

Submitted by anonymous on Jul 22, 2018 at 09:46
Language: C++. Code size: 693 Bytes.

/*
	根据统计结果得到时长隶属函数 
*/ 
#include<bits/stdc++.h>
using namespace std;
int type,l,r,num[4][20],cnt;
int main()
{
	freopen("data.txt","r",stdin);
	freopen("data_processed.xls","w",stdout);
	while (cin >> type)
	{
		cnt ++;
		for (int i = 1;i<=3;++i)
		{
			cin >> l >> r;
			if (type == 4) continue;
			if (l>r) swap(l,r);
			for (int j = 0;j<=10;++j)
			 if (l<=j && j<=r) num[i][j]++;
		}
	}
	cout << '\t';
	for (int i = 0;i<=10;++i) cout << i << '\t';
	puts(""); 
	for (int i = 1;i<=3;++i)
	{
		cout << (i == 1 ? "0~12" : (i == 2 ? "12~15" : "15~18")) << '\t';
		for (int j = 0;j<=10;++j)  	printf("%.3lf\t",1.0 * num[i][j] / cnt);
		puts("");
	}
	return 0;
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).