Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<string>
- int main()
- {
- int broj=9999;
- while (broj!=0)
- {
- for (;;)
- {
- std::cout<<"Unesite broj ili 0 za kraj \n\n";
- std::cin>>broj;
- if (std::cin) break;
- std::cout<<"Unesite broj: \n";
- std::cin.clear();
- std::cin.ignore(100000, '\n');
- }
- if(broj==0) break;
- int suma(0);
- for (int i(1); i<=broj; i++)
- {
- if (broj%i==0) suma+=i;
- }
- std::cout<<"Suma svih djelilaca broja " << broj << " je " << suma<<std::endl<<std::endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment