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

为什么是WA?

Posted by silentdi at 2009-03-12 20:54:38 on Problem 2174
#include <iostream>
using namespace std;
int main()
{
    char n_b_msg[20100];
    char b_msg[20100];
    int mid_num1;
    int mid_num2 = 32;
    unsigned int i, j, len;

    cin >> n_b_msg;
    cin >> b_msg;

    len = strlen(n_b_msg);
    for (i=0; i<len; i++)
    {
        if (n_b_msg[i]>='0' && n_b_msg[i]<='9')
            n_b_msg[i] -= '0';
        else
            n_b_msg[i] = n_b_msg[i] - ('A' - 10);
    }

    for (i=0; i<len+2; i++)
    {
        if (b_msg[i]>='0' && b_msg[i]<='9')
            b_msg[i] -= '0';
        else
            b_msg[i] = b_msg[i] - ('A' - 10);
    }

    mid_num1 = b_msg[0] * 16 + b_msg[1];
    mid_num2 = mid_num1 ^ mid_num2;
    printf("%X", mid_num2);

    for (i=0; i<len/2; i++)
    {
        j = i * 2;
        mid_num1 = n_b_msg[j] * 16 + n_b_msg[j + 1];
        mid_num1 = mid_num1 ^ mid_num2;

        mid_num2 = b_msg[j+2] * 16 + b_msg[j + 3];
        mid_num2 = mid_num1 ^ mid_num2;
        printf("%X", mid_num2);
    }

    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