Blogtrottr
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中
程式 C++ 幫忙解答
May 6th 2013, 09:31

long long G ; 輸入一個N-M的數為G

int i ; i 為G的尾數
while ( scanf ("%lld",&G ),G ) {
int first = 0 ; 初值為0
for( i=9 ; i>=0; i-- ) { 因為尾數會是0-9
if( (G-i)%9==0 ) {
if(first) putchar(' ');
first=1;
printf("%lld",(G-i)/9*10+i);
}
}
puts("");
}

誰可幫我解釋每行為什麼要這樣寫
題目為
N是一個大於等於10的整數,有一個莫名其妙叫做John Doe的人,對N發明了一種運算,他把最後一個位數砍掉,形成一個新的數M,然後再算出(N-M),這件事讓他有一種難以言喻的興奮,最後他會告訴你N-M。由於被這有趣的事情感動,你立定目標要找出原來的N到底是多少。
Input
輸入含有多組測試資料。每組測試資料一列有一個正整數(範圍介於10到1018之間),代表John告訴你的數,也就是N-M的值。
若N=0代表輸入結束。請參考Sample Input。
Output
對每組測試資料出一列,輸出所有可能的N。如果超過一個,請由小到大輸出,數之間以一空格區隔。

拜託很急

This entry passed through the Full-Text RSS service — if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers. Five Filters recommends: Thatcher's Tyrants - The Tanks, The Guns, The Christmas Cards.

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions
arrow
arrow
    全站熱搜

    ksokf 發表在 痞客邦 留言(0) 人氣()