海洋之心


私信TA

用户名:wanggongsheng

访问量:122489

签 名:

等  级
排  名 17
经  验 20491
参赛次数 3
文章发表 163
年  龄 26
在职情况 学生
学  校
专  业 计算机技术

  自我简介:

读研ing,平时不登录dotcpp

#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<sstream>
using namespace std;
int fac(int x)
{
    return x>=0 && x<=255;
}
int main(void)
{
    string line ;
     while(getline(cin , line))
     {
         char str[100] ,ch , *p=str;
          int a, b , c ,d , flag = 1;
         strcpy(str,line.c_str());
          while(*p){ if( isalpha(*p) || *p=='-'){ flag = 0 ;break;} p++;}
         if(flag){     flag = 0 ;
         stringstream ss(line);
         ss >> a >> ch>> b>> ch>>c >> ch>> d;
          if(fac(a) && fac(b) && fac(c) && fac(d)) flag=1;
         }
         if(flag) printf("Y\n"); else  printf("N\n");
     }
    return 0 ;
}

解题思路:





注意事项:





参考代码:

 

0.0分

1 人评分

  评论区