「已注销」 2018-12-01 00:34 采纳率: 100%
浏览 405
已结题

超级小白一枚,问个简单的c++问题

#include
using namespace std;

int* order (int* const list,int size);

int main()
{ int size;
cout<<"数组的大小为:"< cin>>size;
int* list =new int [size];
cout<<"请输入数组元素:"<<endl;

for (int i=0;i<size;i++) 
{cin>>list[i];}

for(int j=0;j<size;j++)
{cout<<&list[j]<<"为"<<list[j]<<"所对应的指针指向的地址."<<endl;}

order(list,size);
cout<<"按升序输出数组元素为:"<<endl; 
for (int k=0;k<size;k++)
{cout<<*(list+k)<<" ";

delete []list;

return 0;

}

int* order (int* const list,int size)
{
for(int l=0;l { for (int j=l+1;j { if(list1[l]>list1[j])
{
int tem;
tem=list1[l];
list1[l]=list1[j];
list1[j]=tem;
}
}
}

return list;

}

编译时老是显示:
[Error] a function-definition is not allowed here before '{' token
[Error] expected '}' at end of input

  • 写回答

4条回答 默认 最新

  • superwarner 2018-12-01 00:45
    关注

    没太看明白你的CODE,
    cout<<"按升序输出数组元素为:"<<endl;
    for (int k=0;k<size;k++)
    {cout<<*(list+k)<<" "; 这里为什么没有“}”
    能不能写得有indent

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000