Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
朴素算法过 题目真水#include <iostream> using namespace std; char twoBitNum[32]; int map[8]={128,64,32,16,8,4,2,1}; int IPAdr[4]; void input(); void standerlize(); void output(); void clear(); int main() { int n; cin>>n; cin.ignore(33,'\n'); for (int i=0;i<n;i++) { clear(); input(); standerlize(); output(); } return 0; } void input() { for (int j=0;j<32;j++) { cin>>twoBitNum[j]; } } void clear() { for (int j=0;j<4;j++) { IPAdr[j]=0; } } void output() { for (int j=0;j<3;j++) { cout<<IPAdr[j]<<'.'<<flush; } cout<<IPAdr[3]<<endl; } void standerlize () { for (int j=0;j<4;j++) { for (int k=0;k<8;k++) { if (twoBitNum[j*8+k]=='1') IPAdr[j]+=map[k]; } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator