题解 | IP地址
#include<bits/stdc++.h> using namespace std; int a[4] = {256, 256, 256, 256}; int main(){ //scanf格式化读取即可 while(scanf("%d.%d.%d.%d", a, a+1, a+2, a+3)!=EOF){ bool flag = false; for(int i=0; i<4; ++i){ if(a[i]<0 || a[i]>255) { flag = true; break; } a[i] = 256; } if(flag) cout<<"No!\n"; else cout<<"Yes!\n"; } return 0; }