含奶嘴打代码


私信TA

用户名:18718371621

访问量:42516

签 名:

等  级
排  名 129
经  验 7433
参赛次数 1
文章发表 67
年  龄 0
在职情况 学生
学  校 青蛙小学
专  业

  自我简介:

解题思路:

注意事项: 坑爹的题目

参考代码:

#include<iostream>

#include<string>

#include<algorithm>

#include<string.h>

using namespace std;

int f(string s){

if(!isdigit(s[0]))

return 0;

int t = 0;

for(int i=0; i<s.length(); i++)

if(!isdigit(s[i]))

return 0;

else

t = t*10 + s[i]-'0';

if(t>255)

return 0;

return 1;

}

int main(){

char s[100];

while(scanf("%s",s) != EOF){

string t;

int i=0;

int n = 4;

while(n--){

for(; i<strlen(s); i++)

if(s[i] != '.')

t += s[i];

else{

i++;

break;

}

if(!f(t))

break;

t = "";

}

if(n>=0)

cout<<'N'<<endl;

else

cout<<'Y'<<endl;

}

return 0;

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区