asmodeus94

whileSr

Oct 9th, 2012
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include<iostream>    
  2. #include<cstdio>      
  3. using namespace std;
  4. void zad1(){
  5. int a,b,mod=0;
  6. cout<<"Liczby podzielne przez 3:";
  7. do{
  8. ++a;
  9. if (a%3==0) cout<<a<<" ";
  10. }while(a!=30);
  11. getchar();getchar();
  12. }
  13. void zad2(){
  14. int a=0;
  15. do{
  16. ++a;
  17. cout<<a<<" - ";
  18. if (a%2==0) cout<<"parzysta\n";else cout <<"nieparzysta\n";
  19. }while(a!=20);
  20. getchar();getchar();
  21. }
  22. void zad3(){
  23. int a,licz,sum=0;
  24. float sr=0;
  25. a=1;
  26. while(a!=0){
  27. system("cls");
  28. cout<<"Podaj liczbe: ";cin>>a;
  29. if (a!=0){++licz;sum+=a;sr=sum/licz;}
  30. }
  31. cout << "Podales "<<licz<<" liczb\n";
  32. cout <<"Suma tych liczb wynosi: "<< sum<<endl;
  33. cout << "Srednia: "<<sr;
  34. getchar();getchar();
  35. }
  36. int main(){    
  37. int wyb;
  38. do{
  39. system("cls");
  40. cin>>wyb;
  41. switch(wyb){
  42. case 1: zad1();break;
  43. case 2: zad2();break;
  44. case 3: zad3();break;
  45. }
  46. }while(wyb!=0);
  47. }
Advertisement
Add Comment
Please, Sign In to add comment