Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  4.  
  5. void suma() {
  6. int a=0, b=0, c=0;
  7. cout<<"Podaj sumę liczb: ";
  8. cin>>a;
  9. for(int i=0;i<a;i++){
  10. b=b+1;
  11. c=c+b;
  12. cout<<b<<endl;
  13. }
  14. cout<<"Razem: "<<c;
  15. }
  16. void sl() {
  17. int a=0, b=0, c=1;
  18. cout<<"Podaj sumę liczb: ";
  19. cin>>a;
  20. for(int i=0;i<a;i++){
  21. b=b+1;
  22. c=c*b;
  23. cout<<b<<endl;
  24. }
  25. cout<<"Razem: "<<c;
  26. }
  27.  
  28. main() {
  29. char w;
  30. cout<<"Suma a | silnia b | ";
  31. cin>>w;
  32. switch(w) {
  33. case 'a': {
  34. suma();
  35. break;
  36. }
  37. case 'b': {
  38. sl();
  39. break;
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement