Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication1.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <vector>
- using namespace std;
- vector<int> myVec;
- int dodaj(int a, int b) {
- return (a + b);
- }
- int main()
- {
- //Drukowanie dlugosci vectora - obecnie 0
- cout << myVec.size() << endl;
- //Dodawanie 0 na koniec
- myVec.push_back(0);
- //bedzie 1
- cout << myVec.size() << endl;
- //Dodaje 1 na koniec
- myVec.push_back(1);
- //Wydrukuje 2
- cout << myVec.size() << endl;
- //Przyklad petli
- //Tak długo jak i jest mniejsza od 5 wykonuj zadanie
- //Za każym wykonaniem zadania dodawaj 1 do i
- //Jesli i bedzie wieksze lub rowne 5 przestanie sie wykonywac petla
- //for (int i = 0; i < 5; i++){
- //
- //}
- cout << "Drukowanie elementow: " << endl;
- //Tak dlugo jak I jest mniejsza od długosci vectora wykonuj zadanie
- for (int i = 0; i < myVec.size(); i++) {
- cout << "Element dla i rownego: " << i << endl;
- cout << myVec[i] << endl;
- }
- char x;
- cin >> x;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement