Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- std::vector <int> wprowadz(){
- int amount;
- std::vector <int> tab;
- std::cout<<"Podaj ilosc liczb"<<std::endl;
- std::cin>>amount;
- for (int i=0;i<amount;i++){
- int liczba;
- std::cout<<"Podaj liczbe"<<std::endl;
- std::cin>>liczba;
- tab.push_back(liczba);
- }
- return tab;
- }
- int policz(std::vector <int> tab){
- int counter=0;
- for (int i=0;i<tab.size();i++){
- if (tab[i]%3==0){
- counter++;
- }
- }
- return counter;
- }
- int main() {
- std::vector <int> tab = wprowadz();
- std::cout<<"Ilosc podzielnych przez 3: "<<policz(tab);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement