I want to type this form in my program: s1[k[I]], but it doesn't let me. How can I fix this? Here's my code:
#include <iostream>
using namespace std;
int main(){
int N;
cin>>N;
string s1[N];
for(int k=0;k<N;k++)
{
cin >> s1[k];
}
int counter=0;
for(int k=0;k<N-1;k++)
{
for(int i=0;i<s1[k].size();k++)
{
if(s1[k[i]] == s1[k[i]])
{
cout << s1[k][i] << endl;
}
}
}
return 0;
}
k[i]supposed to do? Ask yourself: What is the type ofk?k[i]mean, whenkis declared asint k=0;?kis not an array sos[k[i]]makes no sense, did you means1[k][i]like you wrote on the next line?s1[k[i]]when would it ever not be the case thats1[k[i]]==s1[k[i]]? You are compaing to identical expressions with each other, that's always going to be true.