Skip to main content

Compare the Triplets Hackerrank Solution in C

#include<stdio.h>
int main()
{
int a[1000],b[1000],i,a1=0,b1=0;
for(i=0;i<3;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<3;i++)
{
scanf("%d",&b[i]);
}
for(i=0;i<3;i++)
{
if(a[i]==b[i])
{
}
else if(a[i]>b[i])
{
a1++;
}
else
{
b1++;
}
}
printf("%d %d",a1,b1);

return 0;
}

Comments

Popular posts from this blog

Breaking the Records Hackerrank solution in C

#include< stdio.h > int main() { int n,i,a[ 1000 ],x= 0 ,mn= 0 ; scanf( "%d" ,&n); for (i= 0 ;i<n;i++) { scanf( "%d" ,&a[i]); } int min=a[ 0 ],max=a[ 0 ]; for (i= 0 ;i<n;i++) { if (min>a[i]) { min=a[i]; mn++; } } for (i= 0 ;i<n;i++) { if (max<a[i]) { max=a[i]; x++; } } printf( "%d %d" ,x,mn); return 0 ; }