c++ 60玄关求调
查看原帖
c++ 60玄关求调
844625
Andy66楼主2024/9/19 13:17
#include<bits/stdc++.h>
using namespace std;
int a[10010],b[10010],c[1010];
void get(int a[]){
	string s;
	cin>>s;
	a[0]=s.size();
	for(int i=a[0]-1;i>=0;i--)
		a[a[0]-i]=s[i]-'0';
	while(a[a[0]]==0&&a[0]>1)
		a[0]--;
}
void f(int a[],int b[],int c[]){
	for(int i=1;i<=a[0];i++){
		if(a[i]<b[i]){
			a[i+1]--;
			a[i]+=1;
		}
		c[i]=a[i]-b[i];
	}
	c[0]=a[0];
	while(c[c[0]]==0&&c[0]>1)
		c[0]--;
}
void put(int a[]){
	for(int i=a[0];i>=1;i--)
		cout<<a[i];
	cout<<endl;
}
int main(){
	memset(a,0,sizeof(int));
	memset(b,0,sizeof(int));
	memset(c,0,sizeof(int));
	get(a);
	get(b);
	f(a,b,c);
	put(c);
	return 0;
}

2024/9/19 13:17
加载中...