不用类,不用其它系统函数,不用指针。请高手们看下边这段程序错误在哪?(程序能过编译通过,但是结果并不是欲想的结果)如下:
#include<iostream>
#include<string>
using namespace std;
int main()
{
void sort(string b[]);
int i;
string a[5];
cout<<“输入5个字符串:“<<endl;
for(i=0;i<5;i++)
{
cout<<“第“<<i+1<<“个字符串:“;
cin>>a[i];
}
sort(a);
return 0;
}
void sort(string b[])
{
int i,j,p;
string temp;
for(i=0;i<5;i++)
for(j=0;j<5-i;j++)
if(b[j]<b[j+1])
{
temp=b[j];
b[j]=b[j+1];
b[j+1]=temp;
}
cout<<“输入的5个字符串从小到大排序为:“<<endl;
for(p=0;p<5;p++)
cout<<b[p]<<endl;
cout<<endl;
}