Блог пользователя hussein_96

Автор hussein_96, 12 лет назад, По-английски

In problem 266A eclipse tell me this error : comparison with string literal results in unspecified behaviour [-Waddress] and tell me that the error is here if (q[i] == "B" && q[i+1] == "G") my code ~~~~~

include

include

using namespace std ;

int main(){

int n , time ;

cin >> n >> time ;

char q[n][10];

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

cin >> q[i];

}

for (int l = 0 ; l<time ; l++){

for (int i = 0 ; i<n ; i++){ if (q[i] == "B" && q[i+1] == "G"){

    swap(q[i],q[i+1]);

}

} }

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

cout <<q[i];

}

}

~~~~~

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

a little googling got me this