posted on 2007-09-20 18:10 流牛ζ木马 阅读(1020) 评论(2) 编辑 收藏 引用
# include <iostream.h> int main() { int n; cin >> n; for (int i = 0; i < n; ++i) { for (int j = 0; j < 4; ++j) { int d = 0; for (int k = 0; k < 8; ++k) { char b; cin >> b; d = (2 * d + (b - '0')); } cout << d; if (j < 3) { cout << "."; } } cout << endl; } return 0; } 回复 更多评论
#include <stdio.h>#include <stdlib.h>int main(){ int times,i,j; scanf("%d",×); char *p; p=(char *)malloc(33*sizeof(char)); for(i=0;i<times;++i) { scanf("%s",p); int a[4]={0},t=256; for(j=0;j<32;j++) { t/=2; a[j/8]+=(p[j]-'0')*t; if(t==1)t=256; } printf("%d.%d.%d.%d\n",a[0],a[1],a[2],a[3]); } return 0;} 回复 更多评论
Powered by: C++博客 Copyright © 流牛ζ木马