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

快崩溃了,找不出问题,求哪位大神帮一下忙,感激!!

Posted by Ben_3738 at 2012-10-31 15:30:45 on Problem 1007
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int n,m,i,j,k,key;
    int count[110],c[110];
    char a[5010],poj;
    scanf("%d %d\n",&n,&m);

       for(i=1;i<=(n+1)*m;i++)
            {
            scanf("%c",&a[i]);

            }
        for(i=1;i<=m;i++)
            {count[i]=0;
            for(j=(i-1)*(n+1)+1;j<=i*(n+1)-1;j++)
                for(k=j+1;k<=i*(n+1)-1;k++)
                    {if(a[j]>a[k]) count[i]++;}
            }
        for(i=1;i<=m;i++)c[i]=i;
        for(i=1;i<=m;i++)
            {
            for(j=i+1;j<=m;j++)
                {
                    if(count[i]>count[j])
                    {   poj=count[i];count[i]=count[j];count[j]=poj;
                        poj=c[i];c[i]=c[j];c[j]=poj;
                    }
                }


        }
        for(i=1;i<=m;i++)
            for(j=(c[i]-1)*(n+1)+1;j<=c[i]*(n+1);j++)
                printf("%c",a[j]);



}

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