Advertisement
kolezka

Untitled

Oct 23rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. // ConsoleApplication1.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <vector>
  7.  
  8. using namespace std;
  9.  
  10. vector<int> myVec;
  11.  
  12.  
  13. int dodaj(int a, int b) {
  14.     return (a + b);
  15. }
  16.  
  17. int main()
  18. {
  19.     //Drukowanie dlugosci vectora - obecnie 0
  20.     cout << myVec.size() << endl;
  21.     //Dodawanie 0 na koniec
  22.     myVec.push_back(0);
  23.     //bedzie 1
  24.     cout << myVec.size() << endl;
  25.     //Dodaje 1 na koniec
  26.     myVec.push_back(1);
  27.     //Wydrukuje 2
  28.     cout << myVec.size() << endl;
  29.  
  30.     //Przyklad petli
  31.     //Tak długo jak i jest mniejsza od 5 wykonuj zadanie
  32.     //Za każym wykonaniem zadania dodawaj 1 do i
  33.     //Jesli i bedzie wieksze lub rowne 5 przestanie sie wykonywac petla
  34.     //for (int i = 0; i < 5; i++){
  35.     // 
  36.     //}
  37.     cout << "Drukowanie elementow: " << endl;
  38.     //Tak dlugo jak I jest mniejsza od długosci vectora wykonuj zadanie
  39.     for (int i = 0; i < myVec.size(); i++) {
  40.         cout << "Element dla i rownego: " << i << endl;
  41.         cout << myVec[i] << endl;
  42.  
  43.     }
  44.  
  45.     char x;
  46.     cin >> x;
  47.  
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement