2017-01-09 5 views
0

나는 문제를 겪었고, 나는 택시 프로그램을 학교에 만들어야 만했다. 그래서 내가 자동차를 갈아 타기 위해 옵션을 줄 필요가있다. 그러나 사용자가 진행하기 위해서는 번호판을 줄 필요가 있습니다. 난 경우 3, 구조체에이 개 차량을 추가하면 프로그램은 내가 당신이 for 루프를 추가하는 것을 잊었다 생각 번호판 등 올바른 일 ...C 첫 번째 번호판을 읽는 프로그램 만

void alterarDisponiblidadeTaxi (TAXIS taxis[], int qtd_taxis){ 
int i=0; 
char matr[10]; 
if(0>=qtd_taxis){ 
    printf("No data has given yet!\a\n"); 
    return; } 
printf("Insert the vehicle's plate:\n"); 
scanf("%s",matr); 

if (strcmp(matr,taxis[i].matricula) == 0){ 
    printf("License plate found with sucess!\n"); 
    return 0; 
} 
if (strcmp(matr,taxis[i].matricula) != 0){ 
     printf("License plate not found with sucess!\a\n"); 
     return 0; 
} 
} 

답변

1

을 받고있다. i=0으로, 첫 번째 번호판 만 확인합니다.

void alterarDisponiblidadeTaxi (TAXIS taxis[], int qtd_taxis){ 
    int i=0; 
    char matr[10]; 
    if(0>=qtd_taxis){ 
     printf("No data has given yet!\a\n"); 
     return; } 
    printf("Insert the vehicle's plate:\n"); 
    scanf("%s",matr); 

    for(int i=0; i<qtd_taxis; i++) { 
     if (strcmp(matr,taxis[i].matricula) == 0){ 
      printf("License plate found with sucess!\n"); 
      return 0; 
     } 
    } 

    printf("License plate not found with sucess!\a\n"); 
    return 0; 
} 
+0

어쨌든 고마워하지만 나는 이미 작업을 고쳤으며 교사에게 메일을 보냈습니다. –