fork download
  1. #include <iostream>
  2. #include<string>
  3. using namespace std;
  4.  
  5. const int num_of_planes=1000;
  6.  
  7. struct plane_data{
  8. int code;
  9. string model;
  10. int rows;
  11. int nom_of_seats;
  12. string seats[15][100];
  13. };
  14.  
  15. void add_planes(plane_data planes[],int count){
  16.  
  17. cout << "\nEnter Plane Code: ";
  18. cin >> planes[count].code;
  19.  
  20. cout << "Enter Model: ";
  21. cin >> planes[count].model;
  22.  
  23. cout << "Enter Number of Rows: ";
  24. cin >> planes[count].rows;
  25.  
  26. cout << "Enter Number of seats: ";
  27. cin >> planes[count].nom_of_seats;
  28.  
  29.  
  30. cout << "Enter Seats Number: ";
  31. for (int i = 1; i <= planes[count].rows; i++)
  32. {
  33. string seat;
  34. string chair = "a";
  35. string nom_of_chair;
  36. for (int j = 0; j < planes[count].nom_of_seats; j++)
  37. {
  38. nom_of_chair = to_string(i);
  39. seat = chair;
  40. seat = seat.append(nom_of_chair);
  41.  
  42. planes[count].seats[j][i] = seat;
  43. cout << planes[count].seats[j][i] << endl;
  44.  
  45. chair[0]+=1;
  46. }
  47. }
  48.  
  49. count++;
  50. cout << "Plane Added Successfully!\n";
  51. }
  52.  
  53.  
  54. int main(){
  55.  
  56. plane_data planes[num_of_planes];
  57.  
  58. add_planes(planes,0);
  59.  
  60. }
Success #stdin #stdout 0.02s 50448KB
stdin
Standard input is empty
stdout
Enter Plane Code: Enter Model: Enter Number of Rows: Enter Number of seats: Enter Seats Number: Plane Added Successfully!