注意输入
using namespace std; int T; int wrong,ip; int notok(int aa) { if(aa>255 || aa<0) return 1; else return 0; } int main() { cin>>T; for(int step=0;step<T;step++) { int a,b,c,d; scanf(” %d.%d.%d.%d”,&a,&b,&c,&d); wrong=-1; if(notok(a)) {wrong=0;ip=a;} else if(notok(b)) {wrong=1;ip=b;} else if(notok(c)) {wrong=2;ip=c;} else if(notok(d)) {wrong=3;ip=d;} printf(“case #%d:\n”,step); if(wrong==-1) cout<<”Yes”<<endl; else printf(“No %d %d\n”,wrong,ip); } return 0; }
注意输入
include
using namespace std;
int T;
int wrong,ip;
int notok(int aa)
{
if(aa>255 || aa<0) return 1;
else return 0;
}
int main()
{
cin>>T;
for(int step=0;step<T;step++)
{
int a,b,c,d;
scanf(” %d.%d.%d.%d”,&a,&b,&c,&d);
wrong=-1;
if(notok(a)) {wrong=0;ip=a;}
else if(notok(b)) {wrong=1;ip=b;}
else if(notok(c)) {wrong=2;ip=c;}
else if(notok(d)) {wrong=3;ip=d;}
printf(“case #%d:\n”,step);
if(wrong==-1) cout<<”Yes”<<endl;
else printf(“No %d %d\n”,wrong,ip);
}
return 0;
}