Language: C++

#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
using namespace std;
typedef struct aa{	
	int data[110];	
	char fuhao;	
	int length;
}bigdata;
bigdata num1;
bigdata num2;
bigdata result;
void indata(int k);
void adddata();
void subdata(int k);
int cmpabs();
int diff();
int main(){	
	int i,j;	
	int flag=0;	
	indata(1);	
	//indata(2);	
	//indata(3);
	//sub	
	if(diff())	{		
		//cout<<"diff"<<endl;		
		if(cmpabs()==0)		
		{			
			result.length=1;			
			result.fuhao='+';			
			result.data[0]=0;		
		}		
		else		
		{			
			if(num1.fuhao=='-')			
			{				
				if(cmpabs()==1)				
				{					
					result.fuhao='-';					
					subdata(1);				
				}				
				else				
				{					
					result.fuhao='+';					
					subdata(2);				
				}			
			}			
			else			
			{				
				if(cmpabs()==1)				
				{					
					result.fuhao='+';					
					subdata(1);				
				}				
				else				
				{					
					result.fuhao='-';					
					subdata(2);				
				}		
			}		
		}	
	}	
	//add	
	else	
	{		
		//cout<<"add"<<endl;		
		result.fuhao=num1.fuhao;		
		adddata();	
	}	
	//output	
	if(result.fuhao=='-')	
	{		
		cout<<'-';	
	}	
	for(i=0;i<result.length;++i)	
	{		
		if(flag==0)		
		{			
			if(result.length==1)			
			{				
				cout<<result.data[i];			
			}			
			else if(result.data[i]==0)		
			{				
				continue;			
			}			
			else			
			{				
				cout<<result.data[i];				
				flag=1;			
			}		
		}		
		else		
		{			
			cout<<result.data[i];		
		}	
	}	
	cout<<endl;	
	return 0;
}
void indata(int k)
{	
	int i=0;	
	int h=0;	
	char ch;	
	char ss[110];	
	gets(ss);	
	fflush(stdin);	
	if(k==1)	
	{		
		if(ss[0]=='-')		
		{			
			//cout<<"fushu"<<endl;			
			num1.fuhao='-';			
			for(i=0;i<strlen(ss)-1;++i)			
			{				
				num1.data[i]=ss[i+1]-48;			
			}			
			num1.length=i;		
		}		
		else		
		{			
			num1.fuhao='+';			
			for(i=0;i<strlen(ss);++i)			
			{				
				num1.data[i]=ss[i]-48;			
			}			
			num1.length=i;		
		}		
		//cout<<"ss: "<<strlen(ss)<<"length: "<<num1.length<<endl;	
	}	
	else	
	{		
		if(ss[0]=='-')		
		{			
			//cout<<"fushu"<<endl;			
			num2.fuhao='-';			
			for(i=0;i<strlen(ss)-1;++i)			
			{				
				num2.data[i]=ss[i+1]-48;			
			}			
			num2.length=i;		
		}		
		else		
		{			
			num2.fuhao='+';			
			for(i=0;i<strlen(ss);++i)			
			{				
				num2.data[i]=ss[i]-48;			
			}			
			num2.length=i;		
		}		
		//cout<<"ss: "<<strlen(ss)<<"length: "<<num2.length<<endl;	
	}
}
void adddata()
{	
	int i=0,j=0,h=101;	
	int head=0;	
	int jin=0;	
	int va=0;	
	i=num1.length-1;	
	j=num2.length-1;	
	h=101;	
	//cout<<"start "<<" i:"<<i<<" j:"<<j<<endl;	
	while(i>=0&&j>=0)	
	{		
		//cout<<"num1.data["<<i<<"]"<<"="<<num1.data[i]<<"  num2.data["<<j<<"]="<<num2.data[j]<<endl;		
		va=jin+num1.data[i]+num2.data[j];		
		jin=va/10;		
		result.data[h]=va%10;		
		//cout<<"in add loop0 "<<" i:"<<i<<" j:"<<j<<" va:"<<va<<" jin"<<jin<<endl;		
		i--;		
		j--;		
		h--;	
	}	
	if(i>=0)	
	{		
		while(i>=0)		
		{			
			va=jin+num1.data[i];			
			jin=va/10;			
			result.data[h]=va%10;			
			i--;			
			h--;		
		}
	}	
	if(j>=0)	
	{		
		while(j>=0)		
		{			
			va=jin+num2.data[j];			
			jin=va/10;			
			result.data[h]=va%10;			
			j--;			
			h--;		
		}	
	}	
	if(jin!=0)	
	{		
		result.data[h]=jin;		
		h--;	
	}	
	head=h+1;	
	//shift result data to 0 location	
	result.length=101-head+1;	
	for(i=0;i<result.length;++i)	
	{		
		result.data[i]=result.data[i+head];	
	}
}
void subdata(int k)
{	
	int i=num1.length-1;	
	int j=num2.length-1;	
	int jie=0;	
	int va=0;	
	int h=101;	
	int head=0;	
	int tw=0;	
	if(k==1)	
	{		
		while(i>=0&&j>=0)		
		{			
			va=num1.data[i]-jie-num2.data[j];			
			jie=(va<0)?1:0;			
			result.data[h]=(va<0)?(va+10):va;			
			i--;			
			j--;			
			h--;		
		}		
		if(i>=0)		
		{			
			while(i>=0)			
			{				
				va=num1.data[i]-jie;				
				jie=(va<0)?1:0;				
				result.data[h]=(va<0)?(va+10):va;				
				i--;				
				h--;			
			}		
		}		
		if(j>=0)		
		{			
			//impossible		
		}		
		if(jie!=0)		
		{			
			//impossible		
		}		
		head=h+1;		
		//shift result data to 0 location		
		result.length=101-head+1;		
		for(i=0;i<result.length;++i)		
		{			
			result.data[i]=result.data[i+head];		
		}	
	}	
	else	
	{		
		tw=i;		
		i=j;		
		j=tw;		
		while(i>=0&&j>=0)		
		{			
			va=num2.data[i]-jie-num1.data[j];			
			jie=(va<0)?1:0;			
			result.data[h]=(va<0)?(va+10):va;			
			i--;			
			j--;			
			h--;		
		}		
		if(i>=0)		
		{			
			while(i>=0)			
			{				
				va=num2.data[i]-jie;				
				jie=(va<0)?1:0;				
				result.data[h]=(va<0)?(va+10):va;				
				i--;				
				h--;			
			}		
		}		
		if(j>=0)		
		{			
			//impossible		
		}		
		if(jie!=0)		
		{			
			//impossible		
		}		
		head=h+1;		
		//shift result data to 0 location		
		result.length=101-head+1;		
		for(i=0;i<result.length;++i)		
		{			
			result.data[i]=result.data[i+head];		
		}	
	}
}
int cmpabs()
{	
	int i=0;	
	if(num1.length>num2.length)
	{		
		return 1;	
	}	
	else if(num1.length<num2.length)	
	{	
		return -1;	
	}	
	else	
	{		
		for(i=0;i<num1.length;++i)		
		{			
			if(num1.data[i]==num2.data[i])			
			{				
				continue;			
			}			
			else			
			{				
				if(num1.data[i]>num2.data[i])				
				{					
					return 1;				
				}				
				else				
				{					
					return -1;				
				}			
			}		
		}	
	}	
	return 0;
}
int diff()
{	
	if(num1.fuhao!=num2.fuhao)	
	{		
		return 1;	
	}	
	else
	{		
		return 0;	
	}
}

Compiler output:
a.cc: In function 'void indata(int)':
a.cc:110:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
  110 |         gets(ss);
      |         ^~~~
      |         getw