avukas

Untitled

Feb 24th, 2014
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4.  
  5. using namespace std;
  6.  
  7.  
  8. int main()
  9. {
  10. int suma=0, n;
  11. cout <<"Unesite prirodan broj n:\n"<< endl;
  12. cin >>n;
  13.  
  14. while ((!cin) || (n<0))
  15. {
  16. cout <<"Neispravan unos. Unesite prirodan broj ponovo: \n" << endl;
  17. cin.clear();
  18. cin.ignore(10000, '\n');
  19. cin>> n;
  20.  
  21. }
  22. while (n!=0) {
  23.  
  24. for (int i=2; i<=n; i++) {
  25.  
  26. if (n%i==0)
  27. suma=suma+i;
  28.  
  29. cout <<"Suma djelioca broja " << n << " je "<<suma<< endl;
  30. cin>>n;
  31. } }
  32.  
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment