rengetsu

Papildoma:Kvadrato_Suma

Nov 30th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int n=0; // musu n skaicius
  6. int sum=0; // galutinis atsakymas
  7. cout<<"N nuo 1 iki 15. Iveskite n skaicio reiksme: ";
  8. cin>>n;
  9. if(n>15 || n<1){cout<<"Netinkama n reiksme!"<<endl;}
  10. else{
  11. while(n>=1)
  12. {
  13. sum+=n*n;
  14. n=n-1;
  15. }
  16. cout<<"Atsakymas: "<<sum<<endl;
  17. }
  18. return 0;
  19. }
Add Comment
Please, Sign In to add comment