CPE 6. You can say 11

 avatar
user_3763047219
c_cpp
2 years ago
670 B
1
Indexable
Never
# include <iostream>
# include <string>
# include <cstdlib>
using namespace std;

int main(){
    string num;
    while(cin>>num){
        int N=num.length();
        int even=0,odd=0;
        if(num!="0"){
        	for(int i=0;i<N;i++){
                if(i%2==0){
                    even=even+(num[i]-'0');
                }
                else{
                    odd=odd+(num[i]-'0');
                }
            }
            if((even-odd)%11==0){
                cout<<num<<" is a multiple of 11."<<endl;
            }
            else{
                cout<<num<<" is not a multiple of 11."<<endl;
            }
        }
    }
}