# UVa 10929 ### 題目連結:[UVa10929](http://domen111.github.io/UVa-Easy-Viewer/?10929) ### 題述: 你的任務是,給你一個正整數 N,判定它是否是 11 的倍數。 --- 每列資料有一個正整數 N,N 最大可能到 ***1000*** 位數。 若 N = 0 代表輸入結束。 --- 對每個輸入的數,輸出是否為 11 的倍數。輸出格式請參考 Sample Output ### c++ code: ```cpp= #include<bits/stdc++.h> using namespace std; int main() { //------------------------------------------------ #ifdef local freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); //------------------------------------------------ string a ; while ( cin >> a ) { int n = 0 ; int m = 0 ; if ( a == "0" ) { break ; } else { for ( int i = 0 ; i < a.length() ; i += 2 ) { n = n + a[i] - 48 ; } for ( int i = 1 ; i < a.length() ; i += 2) { m = m + a[i] - 48 ; } if ( n > m ) { if ( ( n - m ) % 11 == 0 ) { for ( int i = 0 ; i < a.length() ; i++ ) { cout << a[i] ; } cout << " is a multiple of 11." << endl ; } else { for ( int i = 0 ; i < a.length() ; i++ ) { cout << a[i] ; } cout << " is not a multiple of 11." << endl ; } } else { if ( ( m - n ) % 11 == 0 ) { for ( int i = 0 ; i < a.length() ; i++ ) { cout << a[i] ; } cout << " is a multiple of 11." << endl ; } else { for ( int i = 0 ; i < a.length() ; i++ ) { cout << a[i] ; } cout << " is not a multiple of 11." << endl ; } } } } } ``` :::success **``sample input``** 112233 30800 2937 323455693 5038297 112234 0 ::: :::success **``sample output``** 112233 is a multiple of 11. 30800 is a multiple of 11. 2937 is a multiple of 11. 323455693 is a multiple of 11. 5038297 is a multiple of 11. 112234 is not a multiple of 11. ::: #### [返回首頁](https://hackmd.io/@fkleofk/APCS#10929) ###### tags: `APCS選修` `C++` `UVa`