#include<bits/stdc++.h>
using namespace std;
main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n,b=0,t;
cin>>n;
for(int i=1;i<100;i++){
int m;
if(i<10) m=i%10*10;
else m=i%10*10+i/10;
//cout<<m<<' '<<i<<' '<<(i+n)*2<<' '<<m+n<<endl;-我看裡面狀況時用的程式
if(m>99) continue;
else if((i+n)*2==m+n){
cout<<i;
b=1;
break;
}
}
if(b==0) cout<<"no answer";
}
媽媽年齡不能小於18歲,而且n年後不能大於99歲
媽媽年齡不能小於18歲,而且n年後不能大於99歲
AC (3ms, 352KB)
感謝大大的回覆,已通過,謝謝。