Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.cpp
- // WILKUZDZ
- //
- // Created by adrian on 27.11.2015.
- // Copyright (c) 2015 adrian. All rights reserved.
- //
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- const int n = 10;
- float suma = 0;
- int licznik = 0;
- int tab[n] = { 1,3,7,11,12,13,27,3,7,8 };
- cout << "liczby podzielne przez 3 to:";
- for( int i = 0; i < n; i++)
- {
- if ( tab[i] % 3 == 0 )
- suma=suma+tab[i];
- licznik++;
- }
- cout << "Suma liczb podzielnych przez 3 to: " << suma<< endl;
- for( int i = 0; i < n; i++)
- {
- suma=suma+tab[i];
- }
- cout << "Srednia liczb wynosi: " << suma / licznik << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement