Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication4.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include<iostream>
- #include<vector>
- #include<map>
- #include<stdlib.h>
- using namespace std;
- vector<int>generuj(int ile)
- {
- vector<int>wynik;
- for (int i = 0; i < ile; i++)
- {
- int liczba = rand() % 1000;
- wynik.push_back(liczba);
- }
- return wynik;
- }
- vector<vector<int>>generuj(int ilewierszy, int ilekolumn)
- {
- vector<vector<int>>wynik;
- for (int i = 0; i < ilewierszy; i++)
- {
- vector<int>element = generuj(ilekolumn);
- wynik.push_back(element);
- }
- return wynik;
- }
- void wyswietl(vector<int>liczby, char separator = '\t')
- {
- for (int i = 0; i < liczby.size(); i++)
- {
- cout << liczby[i] << separator;
- }
- cout << endl;
- }
- void wyswietl(vector<vector<int>>tab)
- {
- for (int i = 0; i < tab.size(); i++)
- {
- wyswietl(tab[i]);
- }
- cout << endl;
- }
- vector<int>kolumna(vector<vector<int>>tab, int nrkolumny)
- {
- vector<int>wynik;
- for (int i = 0; i < tab.size(); i++)
- {
- int liczba = tab[i][nrkolumny];
- wynik.push_back(liczba);
- }
- return wynik;
- }
- int main()
- {
- vector<int> wynik = kolumna((generuj(5, 5)), 3);
- wyswietl(wynik);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement