Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int n,liczba;
- namespace operacje
- {
- int maax(vector<int> &wektor1)
- {
- int maksimum=wektor1[0];
- for(int i=0;i<n;i++)
- {
- if(wektor1[i]>maksimum)
- maksimum=wektor1[i];
- }
- return maksimum;
- }
- int miin(vector<int> &wektor1)
- {
- int minimum=wektor1[0];
- for(int i=0;i<n;i++)
- {
- if(wektor1[i]<minimum)
- minimum=wektor1[i];
- }
- return minimum;
- }
- int suma(vector<int> &wektor1)
- {
- int suma1=0;
- for(int i=0;i<n;i++)
- suma1+=wektor1[i];
- return suma1;
- }
- }
- using namespace operacje;
- void pobierz(vector<int> &wektor1)
- {
- cout<<"Podaj ile chcesz wpisac liczb do wektora"<<endl;
- cin>>n;
- cout<<"Teraz wpisuj liczby"<<endl;
- for(int i=0;i<n;i++)
- {
- cin>>liczba;
- wektor1.push_back(liczba);
- }
- }
- void wypisz(vector<int> &wektor1)
- {
- cout<<"Najwieksza wartosc wektora to ";
- cout<<maax(wektor1)<<endl;
- cout<<"Najmniejsza wartosc wektora to ";
- cout<<miin(wektor1)<<endl;
- cout<<"Suma to ";
- cout<<suma(wektor1)<<endl;
- }
- int main()
- {
- vector<int> wektor1;
- pobierz(wektor1);
- wypisz(wektor1);
- return 0;
- }
Add Comment
Please, Sign In to add comment