題目5:
程式碼5:
#include <bits/stdc++.h>
using namespace std;
int main(){
int b;
string result = "";
while(cin>>b){
if(b!=0){
if(b%11==0){
result+=to_string(b)+" is a multiple of 11.\n";
}
else{
result+=to_string(b)+" is not a multiple of 11.\n";
}
}
else{
cout<<result;
return 0;
}
}
return 0;
}
題目6:
程式碼6:
#include <bits/stdc++.h>
using namespace std;
void Bangla(long long int n){
while(n>0){
if(n>=10000000){
cout<<" "<<n/10000000<<" kuti";
n%=10000000;
continue;
}
if(100000<=n&&n<10000000){
cout<<" "<<n/100000<<" lakh";
n%=100000;
continue;
}
if(1000<=n&&n<100000){
cout<<" "<<n/1000<<" hajar";
n%=1000;
continue;
}
if(100<=n&&n<1000){
cout<<" "<<n/100<<" shata";
n%=100;
continue;
}
else{
cout<<" "<<n;
break;
}
}
}
int main(){
long long int n;
int t=1;
while(cin>>n){
cout<<setw(4)<<setfill(' ')<<t<<".";
if(n==0) cout<<" "<<0;
if(n>=10000000){
Bangla(n/10000000);
cout<<" kuti";
Bangla(n%10000000);
}
else{
Bangla(n);
}
cout<<"\n";
t++;
}
return 0;
}
以上程式碼參考:
https://weilin1205.github.io/2022/07/28/UVa/CPEbasic/