← Back to topics
Topic

task :: Avion

B
Bedjovski
http://www.z-trening.com/submit.php?submit=7100192254&subm_code=1

where the hell is my problem?
A
Al3kSaNdaR
Instead of if ( A1.find ( "FBI" ) ) you must use if
( A1.find ( "FBI" ) != string :: npos ) , and of course use that with all 5 strings .
B
Bedjovski
did u tried the code? It doesnt open the cmd window..
A
Al3kSaNdaR
Sprry and you need to remove string FBI = FBI ...
B
Bedjovski
thank you very much!
Anyway can you tell me how to add my number who will be in the array with cin?
A
Al3kSaNdaR
If I understood you correctly you mean something like this :


string A[5];

for ( int i = 0; i < 5; i++ )
{

cin >> A[i];

if ( A[i].find ( "FBI" ) != string :: npos ) cout << i + 1 << endl;

}
B
Bedjovski
nah.. It is not connected with this example..

i want the array to be a[n] and i want to enter the numbers of the subjects in the array..

example:

int n,a[n];
cin>>n>>a[n];

but it doesnt work on this way
A
Al3kSaNdaR
Well if you make array size A[N] you can access only elements with indexes 0 .. N - 1, you try A[N + 1] .
B
Bedjovski
Ok valjda nisi me razumeo na engleski ili lose sam se izrazio.
Hteo sam da pitam dali mozes da napravis nizu koju sodrzi "n" elementi(primer cin>>n; i nizata da ima n elementi.. ako vneses 5 da ti izleze a[100]={a,b,c,d,e} a ako vnesis 6 da izleze a[100]={a,b,c,d,e,f}.. nesto ovako sam hteo..
i da nakon to da upises cin>>a>>b>>c.. etc
A
Al3kSaNdaR
Au, mislim da tako nesto ne moze .
B
Bedjovski
daj addni me na msn bedzo_sr@live.com ili skype fbedzovski

ovde je tesko da se razumemo