#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分
0 人评分
C语言程序设计教程(第三版)课后习题8.1 (Java代码)浏览:752 |
钟神赛车 (C++代码)浏览:838 |
C语言程序设计教程(第三版)课后习题10.1 (Java代码)浏览:1383 |
字符串问题 (C语言代码)浏览:1236 |
wu-理财计划 (C++代码)浏览:788 |
【金明的预算方案】 (C++代码)浏览:827 |
A+B for Input-Output Practice (C语言代码)浏览:440 |
2005年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:546 |
C二级辅导-统计字符 (C语言代码)浏览:602 |
A+B for Input-Output Practice (I) (C语言代码)浏览:418 |