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

Re:为什么总是出现runtime error?是不是循环太多了?帮忙啊!大侠们!!

Posted by wfcq2005 at 2007-10-28 21:56:46 on Problem 1007
In Reply To:为什么总是出现runtime error?是不是循环太多了?帮忙啊!大侠们!! Posted by:hansonzh at 2007-10-28 13:01:16
> #include<iostream>
> using namespace std;
> int main()
> {   
>     int n,m,i,j,k,count,min;
>     int sort[50];
>     int flag[50];
>     char str[100][50],temp;
>     cin>>n>>m;
>       
>     for(i=0;i<m;i++)
>     {  
>        for(j=0;j<n;j++)
>           cin>>str[i][j];
>     }
>     cout<<endl; 
>     for(i=0;i<m;i++)
>        {  
>           count=0;
>           for(j=0;j<n-1;j++)
>           {  
>              temp=str[i][j];
>              for(k=j+1;k<n;k++)
>              {   
>                  if((temp-str[i][k])>0)
>                  count++;
>              } 
>           }
>           sort[i]=count; 
>      }
> 
>     for(k=0;k<m;k++)
>     {  
>        min=sort[0];
>        flag[k]=0;             
>        for(i=0;i<m;i++)
>         {
>            if(min>sort[i])
>            {
>                min=sort[i];
>                flag[k]=i;
>            }
>         }
>         sort[flag[k]]=100;
>     }   
>     
>     for(i=0;i<m;i++)
>     {
>        k=flag[i];
>        for(j=0;j<n;j++)
>          cout<<str[k][j];
>        cout<<endl;
>     }
>     
>       system("pause");
>       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