Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream.h>
- void main(){
- int n, i, nr, sum, c, ok, diz, cnt = 0;
- int v[100000];
- cout << "n= "; cin >> n;
- for(i = 0; i < n; i++){
- sum = 0; ok = 1; diz = 2;
- cout << "v[" << i << "]= ";
- cin >> v[i];
- nr = v[i];
- while(nr != 0){
- c = nr % 10;
- sum += c;
- nr /= 10;
- }
- while(ok && diz <= sum / 2){
- if(sum % diz == 0)
- ok = 0;
- diz++;
- }
- if(ok)
- cnt++;
- }
- cout << "\n" << cnt;
- }
Advertisement
Add Comment
Please, Sign In to add comment