想知道为什么全WA
查看原帖
想知道为什么全WA
354157
Sophon_楼主2020/8/1 09:09
#include <bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	int a[100]={0},b[100]={0},c[100]={0};
	char a1[100],b1[100];
	int t1,t2,t3;
	gets(a1);
	gets(b1);
	t1=strlen(a1);
	t2=strlen(b1);
	for(int i=0;i<t1;i++){
		a1[i]=a1[i]-'0';
	}
	for(int i=0;i<t2;i++){
		b1[i]=b1[i]-'0';
	}
	for(int i=t1-1,j=0;i>=0,j<t1;i--,j++){
		a[i]=a1[j];
	}
	for(int i=t2-1,j=0;i>=0,j<t1;i--,j++){
		b[i]=b1[j];
	}
	
	if(t1>t2)t3=t1;
	else t3=t2;
	for(int i=0;i<t3;i++){
		c[i]=c[i]+a[i]+b[i];
		if(c[i]%20>=10){
			c[i+1]+=1;
			c[i]=c[i]-10;
		}
	}
	if(c[t3]!=0)t3++;
	for(int i=t3-1;i>=0;i--){
		cout<<c[i];
	}
	return 0;
}
2020/8/1 09:09
加载中...