#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 人评分
简单的a+b (C语言代码)浏览:585 |
C语言程序设计教程(第三版)课后习题9.3 (Java代码)浏览:1022 |
小明A+B (C语言代码)浏览:1306 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:937 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:501 |
淘淘的名单 (C语言代码)浏览:1164 |
简单的a+b (C语言代码)浏览:622 |
printf基础练习2 (C语言代码)浏览:543 |
C语言程序设计教程(第三版)课后习题7.2 (C语言代码)浏览:812 |
C语言程序设计教程(第三版)课后习题5.5 (C语言代码)浏览:545 |