Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

有点小坑,记得字符数组开大一点 不要开32 = =

Posted by 153401010125 at 2016-12-03 08:55:39 on Problem 2105
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator