HackerRank Solutions – 30 Days of Code – Day 8

Current Buffer (saved locally, editable)

PROGRAM:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
struct phone
{
long int num;
char name[100][100];
}q[100];
int main()
{
int i,j,flag=0;
long int n;
char a[100][100],b,c;
scanf(“%li”,&n);
for(i=0;i<n;i++)
{
scanf(“%s”,q[i].name);
scanf(“%li”,&q[i].num);
}for(i=0;i<n;i++)
scanf(“%s”,a[i]);
for(i=0;i<n;i++)
{
flag=0;
for(j=0;j<n;j++){
if(strcmp(q[j].name,a[i])==0)
{printf(“%s=%li\n”,q[i].name,q[i].num);
flag=1;}
}
if(flag==0)
printf(“Not found\n”);
}
}
OUTPUT:

Congratulations!

You have passed the sample test cases. Click the submit button to run your code against all the test cases.

Input (stdin)
3
sam 99912222
tom 11122222
harry 12299933
sam
edward
harry
Your Output (stdout)
sam=99912222
Not found
harry=12299933
Expected Output
sam=99912222
Not found
harry=12299933
Follow us on Social Media:

Be the first to comment

Leave a Reply

Your email address will not be published.