Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么会错??

Posted by juventus at 2008-02-12 22:30:04 on Problem 2196
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int number(char a)
{
	if (a=='0') return 0;
	if (a=='1') return 1;
	if (a=='2') return 2;
	if (a=='3') return 3;
	if (a=='4') return 4;
	if (a=='5') return 5;
	if (a=='6') return 6;
	if (a=='7') return 7;
	if (a=='8') return 8;
	if (a=='9') return 9;
	if (a=='a') return 10;
	if (a=='b') return 11;
	if (a=='c') return 12;
	if (a=='d') return 13;
	if (a=='e') return 14;
	if (a=='f') return 15;
}
void main()
{
	int a;
	for (a=2992;a<=9999;a++)
	{
		int count1=0,count2=0;
		char str1[5],str2[5];
		itoa(a,str1,10);
		itoa(a,str2,16);
		int i,j;
		for (i=0;i<strlen(str1);i++)
			count1+=number(str1[i]);
		for (j=0;j<strlen(str2);j++)
			count2+=number(str2[j]);
		if (count1==count2)
			cout<<a<<endl;
	}
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator