Необходимо написать программу, которая позволит - Ответ на вопрос по информатике №1252019
Новинка
-37%
Вопрос
Необходимо написать программу, которая позволит ввести с клавиатуры данные о поездах. Также в программе должен быть предусмотрен поиск по пункту назначения поезда. Какая программа выполняет поставленную задачу?- int main (void){ struct train { char *nazn; int numb; char *time; } tr[3]; int i = 0, sum = 0, ch=0; char str[10], search[10]; while(ch!=121) { printf("nEnter information about train (Q - quit): n"); printf("Enter destination of the train: "); gets(tr[i].nazn); printf("Enter number of the train: "); gets(str); tr[i].numb = atoi(str); printf("Enter time of scheduled departure: "); gets(tr[i].time); ++i; printf("Quit? (y/n): "); ch = _getche(); }; printf("nnEnter train destination: "); gets(search); for (i=0; i<3; i++) { if (strcmp(tr[i].nazn,search)==0) { printf("ntTrain number: %d", tr[i].numb); printf("ntTime: %s", tr[i].time); } } if (i>=3) printf("There is no train to this destination"); return 0; }
- int main (void){ struct train { char nazn[40]; int numb; char time[10]; } tr[3]; int i = 0, sum = 0, ch=0; char str[10], search[10]; while(ch!=121) { printf("nEnter information about train (Q - quit): n"); printf("Enter destination of the train: "); gets(tr[i]->nazn); printf("Enter number of the train: "); gets(str); tr[i]->numb = atoi(str); printf("Enter time of scheduled departure: "); gets(tr[i]->time); ++i; printf("Quit? (y/n): "); ch = _getche(); }; printf("nnEnter train destination: "); gets(search); for (i=0; i<3; i++) { if (strcmp(tr[i]->nazn,search)==0) { printf("ntTrain number: %d", tr[i]->numb); printf("ntTime: %s", tr[i]->time); } } if (i>=3) printf("There is no train to this destination"); return 0; }
- int main (void){ struct train { char nazn[40]; int numb; char time[10]; } tr[3]; int i = 0, sum = 0, ch=0; char str[10], search[10]; while(ch!=121) { printf("nEnter information about train (Q - quit): n"); printf("Enter destination of the train: "); gets(tr[i].nazn); printf("Enter number of the train: "); gets(str); tr[i].numb = atoi(str); printf("Enter time of scheduled departure: "); gets(tr[i].time); ++i; printf("Quit? (y/n): "); ch = _getche(); }; printf("nnEnter train destination: "); gets(search); for (i=0; i<3; i++) { if (strcmp(tr[i].nazn,search)==0) { printf("ntTrain number: %d", tr[i].numb); printf("ntTime: %s", tr[i].time); } } if (i>=3) printf("There is no train to this destination"); return 0; }
Ответ
Этот вопрос в коллекциях

Гарантия сдачи без лишних хлопот! ✅🎓 Ответы на тесты по любым дисциплинам, базы вопросов, работы и услуги для Синергии, МЭИ и других вузов – всё уже готово! 🚀 🎯📚 Гарантия качества – или возврат денег! 💰✅












