#include <iostream>
using namespace std;
int main()
{
int number_1,number_2,a,odd/*單*/,even/*雙*/,ans;
while (cin>>number_1){
a=0;
odd=0;
even=0;
number_2=number_1;
while (number_2>0){
number_2/=10;
a++;
}
while (a>0){
even+=number_1%10;
number_1/=10;
a--;
if (a>0){
odd+=number_1%10;
number_1/=10;
a--;
}
else {break;}
}
if (odd-even>0){
cout<<odd-even<<endl;
}
else if (odd-even<0){
cout<<even-odd<<endl;
}
else if (odd-even==0){
cout<<"0"<<endl;
}
}
}
#include
using namespace std;
int main()
{
int number_1,number_2,a,odd/*單*/,even/*雙*/,ans;
while (cin>>number_1){
a=0;
odd=0;
even=0;
number_2=number_1;
while (number_2>0){
number_2/=10;
a++;
}
while (a>0){
even+=number_1%10;
number_1/=10;
a--;
if (a>0){
odd+=number_1%10;
number_1/=10;
a--;
}
else {break;}
}
if (odd-even>0){
cout<<odd-even<<endl;
}
else if (odd-even<0){
cout<<even-odd<<endl;
}
else if (odd-even==0){
cout<<"0"<<endl;
}
}
}
不能直接cin整數
第3子題很多位數會溢位