How can i use if in vector code ?

at lines 25-27 how can i check for all the "psomi" if there is a smaller "basi " and after cout the number of the "psomi " that there is a smaller " basi "

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  #include<iostream>
#include<vector>
using namespace std;

int main(){
	int a, z;
	vector<int> psomi;
	vector<int> basi;
	int num = 0;
	int t = 0;

	cin >> a;

	for (int i = 0; i < a; i++) {
        cin>>a;
		psomi.push_back(i);
	}

	for (int i = 0; i < a; i++) {
    cin>>a;
		basi.push_back(i);
	}


	if (psomi <= basi){
		t++;
	}
	cout << t << endl;

	return 0;
}
To start off, why do you have duplicate cin >> a statements in your for loops? I guarantee something will mess up with your output if you do that.

Also, a vector is a container, and as with all containers, you can't just call if( psomi <= basi); the compiler won't know what you're referring to. Are you talking about how big the vector is (size), or are you talking about a specific thing inside both of them (Vector[index])?

I would suggest starting here, and slowly working that into your code.

http://www.cplusplus.com/reference/vector/vector/?kw=vector
Topic archived. No new replies allowed.