Created
July 22, 2013 07:37
-
-
Save shaina7837/6051970 to your computer and use it in GitHub Desktop.
output is: Input some numbers and then end the input
3
4
5
end
if I use 1st simple for loop, output is 5
if use 2nd one range for loop output is 5 5 5
why ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
main() | |
{ | |
vector<int> v; | |
int number; | |
auto c = 0; | |
cout <<"Input some numbers and then end the input\n"; | |
while(cin>>number){ | |
v.push_back(number); | |
c++; | |
} | |
//for(i = 0; i < c; i++) | |
for(auto i : v) | |
cout << v.at(2) << " "; | |
cout << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment