Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main() {
- int broj;
- do{
- std::cout << "Unesite pozitivan cijeli broj: ";
- std::cin >> broj;
- if(broj < 0) std::cout <<"\n[GRESKA]\n";
- }while(broj < 0);
- int temp(broj), brojac(0);
- while(temp != 0){
- ++brojac;
- temp /= 10;
- }
- std::cout<<"broj znamenki: "<< brojac << std::endl;
- int num(0);
- temp = broj;
- while(temp != 0){
- num = num * 10 + temp%10;
- temp /= 10;
- }
- int suma(0);
- while(num != 0){
- suma += num % 10;
- std::cout<<num%10;
- if(num / 10 != 0) std::cout<<" + ";
- else std::cout<<" = " << suma;
- num /= 10;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement