**
航电oj:IP Address
**
#题目描述
#给你n个字符串 转换为n个IP地址
#一个一个的处理 8个一分
#知识点
灵活运用
#代码
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int data[9]={0,128,64,32,16,8,4,2,1};//便于计算
int ans[5];
char s;
int t,temp,tempsum;
int main()
{
scanf("%d",&t);
while(t--)
{
int flag = 0;
tempsum =0;
for(int i=1;i<=4;i++)
{
tempsum = 0;//八个一份 要制零
for(int j=1;j<=8;j++)
{
cin >> s;//这个用scanf 好像不行 不太懂
int ss = s - '0';//!!!这里是字符转成数字
if(ss)
{
temp = data[j];
tempsum += temp;
}
}
ans[i] = tempsum ;
}
printf("%d.%d.%d.%d\n",ans[1],ans[2],ans[3],ans[4]);
}
return 0;
}
#总结
要细心的弄 不要弄错了 真的搞心态!!!