Ranjith is going to Theni this week end. As the train tickets are unavailable, he decides to go by bus. He books his tickets through a website. Write a program to find whether he booked a window seat or not. Assume that there are maximum 11 rows in a bus.
Input and Output Format: Input consists of two integers. The first integer corresponds to the number of seats per row in the bus. The second integer corresponds to the seat number.
Sample Input and Output 1: Enter number of seats per row 4 Enter the seat number 36 Window Seat
Sample Input and Output 2: Enter number of seats per row 3 Enter the seat number 34 Invalid Seat Number
Sample Input and Output 3: Enter number of seats per row 3 Enter the seat number 20 Aisle Seat
it keeps getting error in one or the other seat here is my code `
#include<stdio.h>
int main()
{
int ncol,seat,col,row=1;
printf("Enter number of seats per row\n");
scanf("%d",&ncol);
printf("Enter the seat number\n");
scanf("%d",&seat);
{
if(seat==ncol*11)
row=seat/ncol;
col=seat%ncol;
seat=row*ncol+col;
if(row%2!=0&&col%2!=0)
{
printf("Invalid Seat Number");
}
else if((seat%3==1||seat%2==0))
{
printf("Window Seat");
}
else
{
printf("Aisle Seat");
}
return 0;
}
}
its working but still not accepted :(
Aucun commentaire:
Enregistrer un commentaire