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 |
有点小坑,记得字符数组开大一点 不要开32 = =#include<iostream> #include<cstdio> using namespace std; int a[8]={128,64,32,16,8,4,2,1}; int n; //数组开大一点就能过 = = char ip[35]; int cal(int s,int e) { int result = 0; for(int i = s - 1; i < e; i++) { if(ip[i] == '1') result += a[ i % 8 ]; } return result; } int main() { scanf("%d",&n); while(n--) { scanf("%s",ip); cout << cal(1,8) << "." << cal(9,16) << "." << cal(17,24) << "." << cal(25,32) << endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator