Advertisement
Guest User

Untitled

a guest
Nov 27th, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. //
  2. // main.cpp
  3. // WILKUZDZ
  4. //
  5. // Created by adrian on 27.11.2015.
  6. // Copyright (c) 2015 adrian. All rights reserved.
  7. //
  8.  
  9. #include <iostream>
  10. #include <cstdlib>
  11.  
  12.  
  13.  
  14.  
  15. using namespace std;
  16.  
  17. int main()
  18. {
  19. const int n = 10;
  20. float suma = 0;
  21. int licznik = 0;
  22. int tab[n] = { 1,3,7,11,12,13,27,3,7,8 };
  23. cout << "liczby podzielne przez 3 to:";
  24. for( int i = 0; i < n; i++)
  25. {
  26. if ( tab[i] % 3 == 0 )
  27. suma=suma+tab[i];
  28. licznik++;
  29.  
  30. }
  31.  
  32. cout << "Suma liczb podzielnych przez 3 to: " << suma<< endl;
  33.  
  34. for( int i = 0; i < n; i++)
  35. {
  36. suma=suma+tab[i];
  37. }
  38.  
  39. cout << "Srednia liczb wynosi: " << suma / licznik << endl;
  40.  
  41.  
  42.  
  43.  
  44.  
  45. system("pause");
  46. return 0;
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement