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 } 
     
     
  • 相关阅读:
    laravel观察者模式使用及注意事项
    所有CM_消息的说明
    编写Delphi控件属性Stored和Default的理解及应用
    DBGrid上设置选择项
    Enter键使用作Tab键
    delphi 向Windows窗口发送Alt组合键的问题
    DBGridEh用法总结三(PivotGrid的汉化)
    delphi FastReport快速入门
    fastreport打印空白行的方法
    VC对话框如何添加WM_ERASEBKGND消息(OnEraseBkgnd函数)及对话框使用位图背景并透明
  • 原文地址:https://www.cnblogs.com/windysai/p/3581369.html
Copyright © 2011-2022 走看看