zoukankan      html  css  js  c++  java
  • 2013 gzhu 校赛

    题目描述:

                        IP Checking

        Time Limit: 2000/1000 MS (Java/Others)            Memory Limit: 128000/64000 KB (Java/Others)

    Problem Description

    An IP address is a 32 bit address formatted in the following way:

    a.b.c.d

    where a, b, c, d are integers each ranging from 0 to 255. Now you are given two IP addresses, first one in decimal form and second one in binary form, your task is to find if they are same or not.

    Input

    Each case starts with two lines.

    First line contains an IP address in decimal form, and second line contains an IP address in binary form. In binary form, each of the four parts contains 8 digits. Assume that the given addresses are valid.

    Output

    For each case, print "Yes" if they are same, otherwise print "No".

    Sample Input

    192.168.0.100
    11000000.10101000.00000000.11001000
    65.254.63.122
    01000001.11111110.00111111.01111010

    Sample Output

    No
    Yes

     

     
      死改死改死改!!!原来"No" 和 "Yes" 输出变成 "NO" 和 "YES" 了,而且还是问asdfgg的,瘀死了 = =!!记录下来是警醒自己以后不能再犯这种错误了!!!
     
     1 #include <iostream>
     2 #include <cstdio> 
     3 #include <cstdlib> 
     4 #include <cstring> 
     5 using namespace std;   
     6 
     7 const int maxn = 50; 
     8 char s2[maxn]; 
     9 int s[5];   
    10 
    11 int main() 
    12 {     
    13     char ch; 
    14     int t1, t2, t3, t4, l1, l2, l, i, j, p, tmp;     
    15     while (scanf("%d%c%d%c%d%c%d", &t1, &ch, &t2, &ch, &t3, &ch, &t4) != EOF)     
    16     {         
    17         scanf("%s", s2);         
    18         l2 = strlen(s2);         
    19         l1 = 7, l = tmp = 0;        
    20         for (i = 0; i < l2; i++)        
    21         {             
    22             if (s2[i] != '.')            
    23             {                 
    24                 p = 1;                
    25                 for (j = 1; j <= l1; j++)                   
    26                     p *= 2;               
    27                 tmp += p * (s2[i]-'0');                
    28                 l1--;           
    29              }             
    30             else           
    31             {                
    32                 s[l++] = tmp;          
    33                 tmp = 0;                
    34                 l1 = 7;             
    35             }         
    36         }         
    37         s[l++] = tmp;      
    38         if (s[0] == t1 && s[1] == t2 && s[2] == t3 && s[3] == t4)           
    39             printf("Yes
    ");         
    40         else            
    41             printf("No
    ");     
    42     }     
    43     return 0; 
    44 } 
     
     
  • 相关阅读:
    c# 启动线程的方式
    c# 打开文件夹获取所有文件
    windows server 2008 R2 SP1 安装SQL Server 2008 R2时提示 "此操作系统不支持此版本的 SQL Server 版本"
    mongodb 备份 指定用户名密码
    c# 线程启动的两种方式与传参
    vs 2015 密钥
    c# 时间格式yyyy-MM-ddTHH:mm:ss
    c# oledb sql 报错 标准表达式中数据类型不匹配
    CentOS下yum安装dnsmasq,并强制替换为最新版
    使用QUOTA(磁盘配额)来限制用户空间
  • 原文地址:https://www.cnblogs.com/windysai/p/3581369.html
Copyright © 2011-2022 走看看