why the for loop execute m-1 times instead of m.
I have used getline()
to enter string instead of cin>>
.
Here is my code.
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <algorithm>
#include <cstdio>
using namespace std;
int main() {
int n;
int m;
int a;
cin >> n >> m;
int arr[10000];
for(int i = 0; i < n; i++) {
cin >> arr[i];
}
char s[200];
ostream_iterator<int> screen(cout," ");
for(int i = 0; i < m; i++) {
cin.getline(s,20);
int p = s[2]-48;
cout << p << endl;
}
}