+ 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.
3 Antworten
+ 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;
}
+ 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
0
Thanks, i will show the code