0
No.5 Lab 7_структуры
Posted by ေမၿမဳိ့သား
on
7:20 AM
in
C++ No.5 for 2nd year
Qus ==>> Сформировать массив,
содержащий сведения о наличии автобусных маршрутов. Структурный тип содержит
поля: номер автобуса, пункт отправления, пункт назначения, интервал движения,
время в пути.
Написать программу, выдающую следующую информацию:
- возможность добраться от пункта А до пункта Б
без пересадок;
- будет ли автобус от пункта А до пункта Б в
течение времени, введенного с клавиатуры;
- возможность добраться от
пункта А до пункта Б за указанное время (с учетом пересадок, не более одной).#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <math.h>
#include <time.h>
using namespace std;
struct sma{
int car_num;
char start_point;
char end_point;
int mile;
int hour;
};
int _tmain(int argc, _TCHAR* argv[])
{
sma ko[50];
int i,n;
cout << "How many ur cars ==> ";
cin >> n ;
for(i=0;i<n;i++)
{
cout << endl;
cout<<"Enter ur car number \t";
cin>>ko[i].car_num;
cout<<"Enter start_point of car \t";
cin>>ko[i].start_point;
cout<<"Enter end_point of car\t";
cin>>ko[i].end_point;
cout<<" how many mile \t";
cin>>ko[i].mile;
cout<<"Enter hour \t";
cin>>ko[i].hour;
cout <<"********************************";
}
cout<<endl;
cout<<"Car list"<<endl;
cout<<"number\ts_point\tE_point\tMile\tTime" <<endl;
for(i=0;i<n;i++)
{ cout<<ko[i].car_num << "\t " <<ko[i].start_point<< "\t "<<ko[i].end_point << "\t "<<ko[i].mile << "\t "<<ko[i].hour <<endl;
}
/*cout<<endl<<endl<<endl;
cout<<"MORE THAN THE FLIGHT HOUR\t"<<b<<"\tLIST IS"<<endl;
cout<<"place.\ttype.\tnum.\tp_name.\trank.\ttime.\tn_group.\t"<<endl;
for(i=0;i<c;i++)
{
if(a[i].time>=b)
{
cout<<a[i].place << ".\t"<<a[i].type << ".\t"<<a[i].num << ".\t"<<a[i].p_name << ".\t"<<a[i].rank << ".\t"<<a[i].time<< ".\t"<<a[i].n_group<< ".\t"<<endl;
}
}
cout<<endl;
cout<<"The Names Of Pilots Aerobatic Team "<<endl<<endl;
cout<<"p_name.\tplace.\t"<<endl<<endl;
for(i=0;i<c;i++)
{
if(strcmp(a[i].n_group,swift)==0)
{
cout<<a[i].p_name <<".\t"<<a[i].place<<".\t" <<endl;
}
}*/
_getch();
return 0;
}
Post a Comment