c++ - Input vector without temporary variable -


this question has answer here:

how input vector without temporary variable(like x in example)?

std::vector<int> a; int n, x; std::cin >> n; (int i=0;i<n;i++) {     std::cin >> x;     a.push_back(x); } 

one possible solution:

int n, x; std::cin >> n; std::vector<int> a(n); (int i=0;i<n;i++){     std::cin >> a[i]; } 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -