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

What's WA?

Posted by myhao at 2010-05-10 19:22:12 on Problem 2572
#include <iostream>
#include <string.h>
#include <stdlib.h>
using namespace std;
char temp[200],a[100],b[100],c[100];
int main(){
	int i;
	while(scanf("%s",temp)!=EOF)
	{
		if(strcmp(temp,"0+0=0")==0)
		{
			printf("True\n");break;
		}
		int len=strlen(temp),ai,bi,ci;
		for(i=len-1,ai=0;i>=0;i--)
		{
			if(temp[i]!='='){
				a[ai]=temp[i];
				ai++;
			}
			else{
				a[ai]='\0';
				ai++;
				i--;
				break;
			}
		}
		for(bi=0;i>=0;i--)
		{
			if(temp[i]!='+'){
				b[bi]=temp[i];
				bi++;
			}
			else{
				b[bi]='\0';
				i--;break;
			}
		}
		for(ci=0;i>=0;i--)
		{
			c[ci]=temp[i];ci++;
		}
		c[ci]='\0';
		int tempa,tempb,tempc;
		tempa=atoi(a);tempb=atoi(b);tempc=atoi(c);
		if(tempc+tempb==tempa)
			printf("Ture\n");
		else
			printf("False\n");
	}
	return 0;
}

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