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

为什么正确的代码用codeblocks运行出错误的结果啊。VC不会。?

Posted by hq572241670 at 2014-04-05 18:45:42 on Problem 2570
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <time.h>
#include <functional>
#include <cctype>
#include <utility>
#include <numeric>
#include <iomanip>
#include <sstream>
#define Mod 1000000007
#define INT 2147483647
#define pi acos(-1.0)
#define eps 1e16
#define lll __int64
#define ll long long
using namespace std;
#define N 207

int mp[N][N],n;

int power(int k)
{
    int i;
    int res = 1;
    for(i=0;i<k;i++)
    {
        res *= 2;
    }
    return res;
}

void floyd()
{
    int i,j,k;
    for(k=1;k<=n;k++)
    {
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=n;j++)
            {
                mp[i][j] = mp[i][j] | (mp[i][k] & mp[k][j]);
            }
        }
    }
}

int main()
{
    int i,j;
    int u,v;
    char ss[28];
    while(scanf("%d",&n)!=EOF && n)
    {
        for(i=0;i<=N;i++)
        {
            for(j=0;j<=N;j++)
                mp[i][j] = 0;
        }
        while(1)
        {
            scanf("%d%d",&u,&v);
            if(u == 0 && v == 0)
                break;
            scanf("%s",ss);
            int len = strlen(ss);
            sort(ss,ss+len);
            int sum = 0;
            for(i=0;i<len;i++)
            {
                sum += power(ss[i]-'a');
            }
            mp[u][v] = sum;
        }
        floyd();
        while(1)
        {
            scanf("%d%d",&u,&v);
            if(u == 0 && v == 0)
                break;
            if(mp[u][v] == 0)
                puts("-");
            else
            {
                vector<int> vi;
                int tmp = mp[u][v];
                while(tmp)
                {
                    vi.push_back(tmp%2);
                    tmp /= 2;
                }
                int siz = vi.size();
                for(i=0;i<siz;i++)
                {
                    if(vi[i] == 1)
                        printf("%c",'a'+i);
                }
                printf("\n");
            }
        }
        printf("\n");
    }
    return 0;
}

这是正确代码,大家可以用codeblocks试试样例数据,运行出错的东西了。

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