#include <iostream>
using namespace std;
int n, a, k;
main(){
cin>>n;
for(k=1; k<=n; k++){
cin>>a;}}
how can I store inputs to use them in future operations, I'm beginner programmer, I'm looking for easiest way for that.
#include <iostream>
using namespace std;
int n, a, k;
main(){
cin>>n;
for(k=1; k<=n; k++){
cin>>a;}}
how can I store inputs to use them in future operations, I'm beginner programmer, I'm looking for easiest way for that.
If you want to read n integers you can use a vector:
#include <iostream>
#include <vector>
int main()
{
int n;
std::vector<int> vec; //Better try to use namespaces
//Some spaces add clarity
std::cin >> n;
vec.resize(n);
for(int k=0; k<n; k++) //Define local varibales relative to loop for iterator
{
std::cin >> vec[k];
}
return 0; //Always return a code at the finish of the program
}