yoyoboyss

Untitled

May 11th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <iostream.h>
  2.  
  3. void main(){
  4. int n, i, nr, sum, c, ok, diz, cnt = 0;
  5. int v[100000];
  6.  
  7. cout << "n= "; cin >> n;
  8. for(i = 0; i < n; i++){
  9. sum = 0; ok = 1; diz = 2;
  10. cout << "v[" << i << "]= ";
  11. cin >> v[i];
  12. nr = v[i];
  13. while(nr != 0){
  14. c = nr % 10;
  15. sum += c;
  16. nr /= 10;
  17. }
  18. while(ok && diz <= sum / 2){
  19. if(sum % diz == 0)
  20. ok = 0;
  21. diz++;
  22. }
  23. if(ok)
  24. cnt++;
  25. }
  26. cout << "\n" << cnt;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment