Laaysa with his friends going to the theatre for a movie. The seating arrangement is triangular in size.
Theatre staffs insisted the audience to sit in odd row if the seat number is odd and in even row if the seat number is even. But the instruction is very confusing for Laaysa and his friends.
So help them with the seating layout so that they can sit in correct seats.
Input:
Single value representing the number of rows in the theatre.
Output:
Print the layout based on the number of rows.
#include <stdio.h> int main() { int n; int i,j,k; scanf("%d",&n); for(i=1;i<=n;i++){ if(i%2==0){ k=2; } else{ k=1; } for(j=1;j<=i;j++){ printf("%d ",k); k +=2; } printf("\n"); } return 0;}
INPUT_1:
7
OUTPUT:
1
2 4
1 3 5
2 4 6 8
1 3 5 7 9
2 4 6 8 10 12
1 3 5 7 9 11 13
INPUT_2:
11
OUTPUT:
1
2 4
1 3 5
2 4 6 8
1 3 5 7 9
2 4 6 8 10 12
1 3 5 7 9 11 13
2 4 6 8 10 12 14 16
1 3 5 7 9 11 13 15 17
2 4 6 8 10 12 14 16 18 20
1 3 5 7 9 11 13 15 17 19 21
Morae Q!
- Conversion of days into year, weeks and days.
- Find if the number is a perfect number or not.
- Compute conversion of Binary to Octal.
- Return the sum of digits in a number.
- Find if a word exists or not in a sentence.
- Convert Numbers into Words.
- Read a word if it consists only of the letters known.
- Check if the string is a dynamic string or not.
- Convert all Uppercase letters to Lowercase and vice-versa.
- Change the string such that there are no matching adjacent characters.
- Find the number of sub-strings which start and end both in 1.
- Find the start and end index of unsorted sub-array.
- Find the maximum number of pairs that can be formed.
- Figure out the number of bubbly words present.
- Check if a string is lapindrome or not even with a middle character.
- Seating layout in a triangular shaped class according to the number of rows.
- Find and Sort a sub-array which makes whole array sorted.
- Seating layout according to the number of rows.
- Find the final states of the bulbs.
- Check if reversing sub array makes the array sorted.