Re: 10035 - Primary Arithmetic
Posted: Tue May 21, 2013 2:46 am
That is AC code.
Why i am getting WA plz help anyone
Code: Select all
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string.h>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
int main()
{
unsigned long int a,b,m,n,t;
int count=0;
while(1)
{
cin>>a>>b;
if(a==0&&b==0){ break;}
while(a%10!=0&&b%10!=0)
{
m=a%10,n=b%10;
t=m+n;
if(t>9)
{
count++;
}
a=a/10,b=b/10;
t=0;m=0,n=0;
}
if(count==0){ cout<<"No carry operation."<<endl; }
else if(count>0)
{
cout<<count<<" carry operation."<<endl;
}
count=0;
}
return 0;
}
Why i am getting WA all test cases are show correct plz help.
give me some test case
Code: Select all
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string.h>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
int main()
{
unsigned long int a,b,m,n,t;
int count=0;
while(cin>>a>>b)
{
if(a==0&&b==0){ break;}
while(a!=0&&b!=0)
{
m=a%10,n=b%10;
t=m+n;
if(t>=10)
{
count++;
}
a=a/10,b=b/10;
t=0;m=0,n=0;
}
if(count==0){ cout<<"No carry operation."<<endl; }
else if(count==1){cout<<count<<" carry operation."<<endl;}
else
{
cout<<count<<" carry operations."<<endl;
}
count=0;
}
return 0;
}
Code: Select all
999 1
0 0
Code: Select all
3 carry operations.
Code: Select all
#include<stdio.h>
int main()
{
long int num1,num2,x,y,carry,crry=0;
while(scanf(" %ld %ld",&num1,&num2)==2 && (num1!=0 || num2!=0))
{
carry=0;
while(num1!=0 || num2!=0)
{
x=num1%10;
y=num2%10;
num1=num1/10;
num2=num2/10;
if(x+y+crry>=10)
{carry++;
crry=1;
}
else
crry=0;
}
if(carry==0)
printf("No carry operation.\n");
else if(carry==1)
printf("1 carry operation.\n");
else
printf("%ld carry operations.\n",carry);
}
return 0;
}
Code: Select all
123 0
0 0
Code: Select all
No carry operation.