題目1.網(wǎng)友年齡
某君新認(rèn)識(shí)一網(wǎng)友。
當(dāng)問(wèn)及年齡時(shí),他的網(wǎng)友說(shuō):
“我的年齡是個(gè)2位數(shù),我比兒子大27歲,
如果把我的年齡的兩位數(shù)字交換位置,剛好就是我兒子的年齡”
請(qǐng)你計(jì)算:網(wǎng)友的年齡一共有多少種可能情況?
提示:30歲就是其中一種可能哦.
請(qǐng)?zhí)顚?xiě)表示可能情況的種數(shù)。
注意:你提交的應(yīng)該是一個(gè)整數(shù),不要填寫(xiě)任何多余的內(nèi)容或說(shuō)明性文字。
第一題是送分題,簡(jiǎn)單的暴力搜索。不用多說(shuō)。
/*name:Rollchuchytype:網(wǎng)友年齡 */#include<iostream>#include<cstdio>using namespace std;int main(){ for(int i=10;i<=99;i++){ int a=i/10; int b=i-10*a; int son=b*10+a; if(i-son==27){ cout<<i<<endl; } } return 0; }
|
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注