Is the SoloLearn IDE limited in C++? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 2

Is the SoloLearn IDE limited in C++?

When I was resolving a problem, called driver's license, I introduced code from Code:Blocks, it works successfully there, but not in SoloLearn IDE. I guess that not allow loops with arrays, it was used for me in that problem.

15th May 2020, 5:48 PM
Garise
Garise - avatar
3 Respuestas
+ 2
This is my code: #include <iostream> #include <stdio.h> #include <string.h> #define N 255 using namespace std; int main(){ /**Vector de cadena*/ char nombres[N]; char name[N]; int agents; cout<<"Write your name"<<endl; cin.getline(name, N); cout<<"Number of Agents"<<endl; cin>>agents; fflush(stdin); cout<<"Names of other drivers: "; gets(nombres); int i=0; int p=0; int q=0; strlwr(nombres); strlwr(name); char vnom[N][N]; while(nombres[i]!='\0') { vnom[p][q]=nombres[i]; q++; if(nombres[i]==' ') { //i++; q--; vnom[p][q]='\0'; q=0; p++; } i++; } i=0; p=0; q=0; int posit=1; while(vnom[p][i]!='\0'){ if(name[q]>vnom[p][i]) { posit++; } while(name[q]==vnom[p][i]) { q++; i++; if(name[q]>vnom[p][i]) { posit++; } } p++; i=0; q=0; } cout<<"Position: "<<posit<<endl; int time=20; if(posit<=agents) { cout<<"Wait time: "<<time<<" minutes"<<endl; } while(posit>agents) { posit=posit-agents; time+=20; if(posit<=agents) { cout<<"Wait time: "<<time<<" minutes"<<endl; } } return 0; }
15th May 2020, 10:14 PM
Garise
Garise - avatar
+ 1
Thanks, about gets, i know that. I forgot to change it, really i wrote cin.getline, about strlwr, i didn't know it, thank you so much. I just wanted to resolve that problem :'c
16th May 2020, 4:59 PM
Garise
Garise - avatar
0
Thanks, i will show the code
15th May 2020, 9:31 PM
Garise
Garise - avatar