1225 - Digit Counting

All about problems in Volume 12. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 1225 - Digit Counting

Post by lighted » Sun Oct 26, 2014 10:34 am

Code: Select all

Use code tags. Like this
You must print newline after each line. Remove condition if (c < n - 1).
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

wencey
New poster
Posts: 2
Joined: Fri Oct 31, 2014 6:08 pm

Re: 1225 - Digit Counting

Post by wencey » Tue Nov 04, 2014 7:16 am

Why my code get WA?
thank you.

Code: Select all

#include<iostream>
#include<string>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<map>

using namespace std;
int main ( )
{
	int a;
	cin >> a;
	for ( int b = 0; b < a; b++ )
	{
		int ads [ 10 ];
		for ( int i = 0; i < 10; i++ )
		{
			ads [ i ] = 0;
		}
		string Input;
		cin >> Input;
		for ( int i = 0; i < Input.length(); i++ )
		{
			stringstream ss;
			ss << Input[i];
			int bdf;
			ss >> bdf;
			ads [ bdf ]++;

		}
		for ( int i = 0; i < 10; i++ )
		{
			cout << ads[i] << ' ';

		}
		cout << endl;
	}
	return 0;
}

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 1225 - Digit Counting

Post by lighted » Tue Nov 04, 2014 3:28 pm

Your code doesn't match sample input/output.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

Post Reply

Return to “Volume 12 (1200-1299)”