Posts

Akash the die heart fan of AR Rahman went to the live concert happened in Bangalore with his family members.The event management firm responsible for the event arranged the seats for the audience in descending order of maximum number of tickets booked for single family.

 #include <stdio.h> int main() {int nooffamilymembers; scanf("%d",&nooffamilymembers); int r=nooffamilymembers; for(int i=1;i<=nooffamilymembers;i++){     for(int j=1;j<=r;j++){         printf("%d ",r);     }r--;     printf("\n");} return 0; }

Advika is trying to solve the puzzle problem during Mathematics class hour. she has a graph paper with G X N rows and columns, and the puzzle question is, an NCC training base in each cell for a total of G X N bases. He wants to drop food items to every point based on strategic points on the graph paper, marking each drop point with a red dot. If a base contains at least one food package inside or on top of its border fence, then it's considered to be supplied. For example: if Advika has four bases in a 2x2 grid. If he drops a single food package where the walls of all four bases intersect, then those four cells can access the food package.

 #include<stdio.h> int req,x,y; int NccCells(int x,int y) {req=((x+1)/2)*((y+1)/2);     return req;} int main() {    scanf("%d%d",&x,&y);     printf("%d",NccCells(x,y)); return 0;}

There are N students standing in a row and numbered 1 through N from left to right. You are given a string S with length N, where for each valid i, the i-th character of S is 'g' if the i-th student is a girl or 'b' if this student is a boy. Students standing next to each other in the row are friends.

 #include<stdio.h> #include<string.h> int main() {     char students[100001];     int t,j,count=0,length;     scanf("%d",&t);     while(t--){     count=0;     scanf("%s",students);     length=strlen(students);         for(j=0;j<length;j++){             if((students[j]=='g'&&students[j+1]=='b')||(students[j]=='b'&&students[j+1]=='g')){             count++;             j++;}             else             continue;}     printf("%d\n",count);}     return 0; }

Lokesh have been given a String S consisting of uppercase and lowercase English alphabets. Lokesh need to change the case of each alphabet in this String. That is, all the uppercase letters should be converted to lowercase and all the lowercase letters should be converted to uppercase.

#include <stdio.h> #include<string.h> int main() {char ch[100]; int length,i;  scanf("%s",ch); length=strlen(ch); for(i=0;i<length;i++) {   if(ch[i]>=65&&ch[i]<=90)   ch[i]=ch[i]+32;   else if(ch[i]>=97)   ch[i]=ch[i]-32; } printf("%s",ch);                return 0; } 

Laaslya is planning to go to the cinema theater to spend her weekend vacation. Her friends Tina, Caleb, and Jocelyn all knew about Laasya's plan. They say we are coming too, but she thinks to ignore them because only Laasya has enough money to pay for the cinema ticket.The puzzle is Tower of Hanoi is a mathematical puzzle where we have three rods and n disks. The objective of the puzzle is to move the entire stack to another rod. the number of the disk will be given as input obeying the following simple rules:1) Only one disk can be moved at a time.2) Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack i.e. a disk can only be moved if it is the uppermost disk on a stack.3) No disk may be placed on top of a smaller disk.

 #include <stdio.h> void tHanoi(int n,char from_rod,char to_rod,char aux_rod)  {     if(n==1){         printf("\nMove disk 1 from rod %c to rod %c",from_rod,to_rod);         return; }     tHanoi(n-1,from_rod,aux_rod,to_rod);     printf("\nMove disk %d from rod %c to rod %c",n,from_rod,to_rod);     tHanoi(n-1,aux_rod,to_rod,from_rod); } int main() {     int num;   scanf("%d",&num);     tHanoi(num,'A','C','B');  return 0;       }

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.

 #include<stdio.h> int main() {int t,i,j,c; scanf("%d",&t); for(i=1;i<=t;i++){     if(i%2==0)     c=2;     else     c=1;     for(j=1;j<=i;j++){         printf("%d ",c);         c+=2;     }printf("\n"); }              return 0;}

Lokesh usually likes to play cricket, but now, he is bored of playing it too much, so he is trying new games with strings. Lokesh's friend Tina gave him binary strings S and R, each with length N, and told him to make them identical. However, unlike Tina, Lokesh does not have any superpower and Tina lets Lokesh perform only operations of one type: choose any pair of integers (i,j) such that 1≤i,j≤N and swap the i-th and j-th character of S.

#include <stdio.h> int main() {     char s[100],r[100];     int t,i,N;     scanf("%d",&t);     while(t--)     {         int count1=0,count2=0;         scanf("%d",&N);         scanf("%s%s",s,r);         for(i=0;i<N;i++)         {             if(s[i]=='1') count1++;             if(r[i]=='1') count2++;         }         if(count1==count2)         printf("YES\n");         else         printf("NO\n");     }     return 0; } 

Nathan wants to implement wildcard pattern matching supporting only the wildcard '?'. The wildcard character '?' can be substituted by any single lower case English letter for matching. He has two strings X and Y of equal length, made up of lower case letters and the character '?'. He wants to know whether the strings X and Y can be matched or not.

#include <stdio.h> #include<string.h> #include<ctype.h> int main()   {int MAX=10;  char a[MAX],b[MAX];  int t;  scanf("%d",&t);  while(t--){  scanf("%s",a);  scanf("%s",b);  int i,  n=strlen(b),no=0;  for(i=0;i<n;i++)  {if(isalpha(a[i])&&isalpha(b[i])&&a[i]!=b[i])  no++;}  if(no>0)  printf("No\n");  else printf("Yes\n"); } return 0; } 

Afghanistan has surrounded by attackers. A truck enters the city. The driver claims the load is food and medicine from Pakistanis. Yasir is one of the soldier in Afghanistan. He doubts about the truck, maybe it's from the siege. He knows that a tag is valid if the sum of every two consecutive digits of it is even and its letter is not a vowel. If the tag is invalid then Yasir need to arrest the driver of the truck with invalid tab. If it is valid the truck is allowed inside the country.Can you help yasir in determine if he need to arrest or allow the truck?

 #include <stdio.h> int main() {int n=0,c=0; char tag[9]; scanf("%s",tag); while(n<8){     if(tag[n+1]=='-')     n+=2;     else if((tag[n]+tag[n+1])%2==0)     c++;     n++;} if(c>=4)printf("Allowed"); else printf("Arrest"); return 0; }

Ambikapathy wants to decorate his girlfriend Amaravathi's house with a series of lights. The number of lights is M. Initially, all the lights are switched off. Ambikapathy finds that there are K numbers of buttons, each of them is connected to a set of lights. Ambikapathy can press any of these buttons. When the button is pressed, it turns on all the lights it’s connected to. Can Ambikapathy accomplish his task to switch on all the lights? If Ambikapathy presses the button such that some lights connected to it are already turned on, they do not change their state, i.e. remain turned on. Help him in his task to impress his valentine.

 #include <stdio.h> int main() {  int  k,m,count=0; scanf("%d %d",&k,&m); while(k--) {  int lights[m];  int i; for(i=0;i<m;i++) { scanf("%d",&lights[i]); } for(i=0;i<m;i++){ if(lights[i]<=m); else{ count+=1; } } } if(count==0){ printf("YES"); } else{ printf("NO"); } return 0; }