1354:IP Checking

Problem Link

Source Code

#include<stdio.h>
#include<string.h>
#include<math.h>
int bin(int n)
{int tem=n,sum=0,co=0;
while(tem!=0)
{sum+=tem%10*pow(2,co);
co++;
tem/=10;
}
return sum;
}
int main()
{
int num1,sum=0,co=0,num2,num3,num4,n1,n2,n3,n4,t,i,tem,temp;
scanf(“%d”,&t);
for(i=1;i<=t;i++)
{sum=0;co=0;
scanf(“%d.%d.%d.%d”,&num1,&num2,&num3,&num4);
scanf(“%d.%d.%d.%d”,&n1,&n2,&n3,&n4);
if(num1==bin(n1)&&num2==bin(n2)&&num3==bin(n3)&&num4==bin(n4))
printf(“Case %d: Yes\n”,i);
else
printf(“Case %d: No\n”,i);

}
return 0;
}

Advertisements

About waprogramming

I am in CSE,from CUET
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s