Platinum Partner

C++ 數字統計

// description of your code here


#include 
using namespace std;

void main()
{
	int in[3], i, cnt[10] = {0}, re;
	printf("輸入三個6個位數的正整數(空白區隔)");
	for(i=0; i<3; i++)
		cin>>in[i];

	for(i=0; i<3; i++)
	{
		while(in[i])
		{
			re = in[i] % 10;
			in[i] = in[i] / 10;
			switch(re)
			{
			case 0:
				cnt[0]++;
				break;
			case 1:
				cnt[1]++;
				break;
			case 2:
				cnt[2]++;
				break;
			case 3:
				cnt[3]++;
				break;
			case 4:
				cnt[4]++;
				break;
			case 5:
				cnt[5]++;
				break;
			case 6:
				cnt[6]++;
				break;
			case 7:
				cnt[7]++;
				break;
			case 8:
				cnt[8]++;
				break;
			case 9:
				cnt[9]++;
				break;
			}
		}
	}

	cout<<"此三個輸入所統計的各個數字出現次數為下\n";
	for(i=0; i<10; i++)
		cout<<"數字"<"<
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}