蛤玮学计网 -- 简单的判断ip
生活随笔
收集整理的這篇文章主要介紹了
蛤玮学计网 -- 简单的判断ip
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
心累 , 狗日的想了好多數據 , ......啥也不說了 我去哭一會 .?
1 #include<stdio.h> 2 #include<string.h> 3 #include<math.h> 4 #include<iostream> 5 #include<limits.h> 6 #include<algorithm> 7 #include<queue> 8 #include<vector> 9 #include<set> 10 #include<stack> 11 #include<string> 12 #include<sstream> 13 #include<map> 14 #include<cctype> 15 using namespace std; 16 // 1 , 三個點 17 // 2 , 判斷數字是否在范圍內 18 // 3 , 字母的話 不合題意 19 // 4 , 最多三個數 20 int main() 21 { 22 int t; 23 char a[55]; 24 scanf("%d",&t); 25 while(t--) 26 { 27 scanf("%s",a); 28 int l=strlen(a),flag=1; //默認 可以 29 int sum=0,count1=0,time=0; 30 for(int i=0;i<l;i++) 31 { 32 if(a[i]=='.') 33 { 34 if(sum<0||sum>255) 35 flag=0; 36 if(time==0||time>3) //判斷兩個點之間 數字的個數 是否符合要求 37 flag=0; 38 time=sum=0; 39 count1++; 40 continue; 41 } 42 if(!(a[i]>='0'&&a[i]<='9')) //如果不是 0 - 9 的話 43 flag=0; // 出現字母啥都別說了 .... 44 sum=sum*10+a[i]-'0'; 45 time++; 46 } 47 if(count1!=3) 48 flag=0; 49 if(flag) 50 printf("Yes\n"); 51 else 52 printf("No\n"); 53 } 54 return 0; 55 }?
轉載于:https://www.cnblogs.com/A-FM/p/5404405.html
總結
以上是生活随笔為你收集整理的蛤玮学计网 -- 简单的判断ip的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【数据迁移】使用传输表空间迁移数据
- 下一篇: uboot学习之三-----uboot启