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 61886510 at 2012-01-19 23:06:52 on Problem 3125
#include<iostream>
#define N 10995
#define inf 100
using namespace std;

int a[N];

int main()
{
    int t,n,m,i,num,max,pos;
    scanf("%d",&t);
    while(t--)
    {
              num=0;
              max=inf;
              scanf("%d%d",&n,&m);
              for(i=0;i<n;i++)
              scanf("%d",&a[i]);
              for(i=0;i<n;i++)
              {
                              if(a[i]>a[m])
                              {
                                           num++;
                                           if(max>a[i])
                                           {
                                                       max=a[i];
                                                       pos=i;
                                           }
                              }//找出比我要打的大的最小的数
              }
              for(i=pos;i<pos+n;i++)
              {
                                    if(a[i%n]==a[m])
                                    num++;//和自己一样大却在自己之前的
                                    if(i%n==m)
                                    break;
              }
              printf("%d\n",num);
    }
    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