題目連結 UVa 10929
輸入一個字串,書判斷是否為11的倍數
11倍數判別法
奇數位相加-偶數位相加 如果是11的倍數,就是11的倍數
這題直接用字串去解決 方便又快速
#include<iostream>
using namespace std;
int main()
{
string str;
int odd,even,i;
while(cin>>str and str!="0")
{
odd=(even=0);
for(i=0;i<str.length();i++)
{
if(i%2==0)
odd+=(int)str[i]-'0';
else
even+=(int)str[i]-'0';
}
if(abs(even-odd)%11==0)
cout<<str<<" is a multiple of 11."<<endl;
else
cout<<str<<" is not a multiple of 11."<<endl;
}
}
UVA
回目錄 學習筆記
CPE 一星 UVa 00100 || The 3n + 1 problem UVa 00272 || TEX Quotes UVa 00299 || Train Swapping UVa 00948 || Fibonaccimal Base UVa 10010 || Bangla Numbers UVa 10019 || Funny Encryption Method UVa 10038 || Jolly jumper UVa 10041 || Vito's Family
Oct 1, 2021題目連結 UVa 12019 中文簡述 給你一個日期,算出在2011是星期幾。 [think] 題目有提到說2011/4/4是星期一 可以得知 2011的第93天是星期一
Sep 28, 2021題目連結 UVa 10929 [think] 先換成二進位 再算出二進位有幾個1 solution: #include<iostream> using namespace std; int main() {
Sep 7, 2021DEC BIN 0 0000 1 0001 2
Sep 7, 2021or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up