| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么编译都通过不了啊.大虾帮我看看.#include <iostream.h>
#include <string.h>
void bubblesort(int r[],char **p,int m);
void main()
{
int m; //数组个数
int n; //数组长度
int i;
int j;
int k;
char **p;
int *p_num;
int *sort;
cin>>n>>m;
cin.get();
p = new char*[m];
p_num = new int[m];
sort = new int[m];
for(i = 0;i < m;i++)
{
p[i] = new char[n+1];
}
for(i = 0;i < m;i++)
{
cin.getline(p[i],n+1);
cin.get();
}
for(i = 0;i < m;i++)
{
p_num[i] = 0;
}
for(i = 0;i < m;i++)
{
for(k = 0;k < n;k++)
{
for(j = k;j < n;j++)
{
if(int(p[i][k]) > int(p[i][j]))
{
p_num[i]++;
}
}
}
}
cout<<endl;
bubblesort(p_num,p,m);
for(i = 0;i < m;i++)
{
for(j = 0;j < m;j++)
{
cout<<p[i][j];
}
cout<<endl;
}
delete []p;
delete []p_num;
delete []sort;
}
void bubblesort(int r[],char **p,int m)
{
char *p_temp;
p_temp = new char[m];
int i,j,exchange;
for (i = 0;i < m;i++)
{
exchange = 0;
for (j = m;j >= i+1;j--)
{
if (r[j] < r[j - 1])
{
strcpy(p_temp,p[j]);
strcpy(p[j],p[j-1]);
strcpy(p[j-1],p_temp);
exchange = 1;
}
}
if(exchange == 0)
{
return;
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator