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

是数组有问题,c++中数组不是这样用的

Posted by hawk at 2005-01-03 11:23:26 on Problem 1007
In Reply To:我是C++的初学者,请问一下这道题目应该怎么输入?为什么我这样的输入有问题? Posted by:jimmyzzxhlh1 at 2005-01-02 17:18:21
> #include<iostream.h>
> int main()
> {
>   const maxn = 10, maxm = 6;
>   char a[maxn,maxm];
>   int b[maxm],c[maxm];
>   int n,m;
>   while (cin>>n>>m);
>   {
>     int i,j,k;
>     for (i = 1; i <= m; i++)
>     {
>       for (j = 1; j <= n; j++)
> 	cin>>a[i,j];  //这一句运行下来总归有问题~
>     }
>     for (i = 1; i <= m; i++)
>       for (j = 1; j < n; j++)
> 	if (a[i,j] > a[i,j + 1]) b[i]+=int(a[i,j]) - int(a[i,j + 1]);
>     for (i = 1; i < m; i++)
>       for (j = i + 1; j <= m; j++)
> 	if (b[i] > b[j])
> 	{
> 	  for (k = 1; k <= n; k++) c[k] = a[i,k];
> 	  for (k = 1; k <= n; k++) a[i,k] = a[j,k];
> 	  for (k = 1; k <= n; k++) a[j,k] = c[k];
> 	}
>     for (i = 1; i <= m; i++)
>     {
>       for (j = 1; j <= n; j++) cout<<a[i,j];
>       cout<<endl;
>     }
>   }
>   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