动态数组问题
#include <iostream>
using namespace std;
void sorted(int * ,int *);
void main()
{
int n;
cout<<" input N :"<<endl;
cin>>n;
int *number = new int[n];
sorted(number , &n);
}
void sorted(int *temp , int *m)
{
int swap;
for(int i=0 ; i <= *m ; i++)
{
if(*temp[i] <= *temp[i+1]);
{
swap = *temp[i+1];
*temp[i+1] = *temp[i];
*temp[i] = swap;
}
}
cout<<"the sorted number :"<<endl;
for(int j=0 ; j < *m ; j++)
{
cout<<*temp[j]<<" ";
}
cout<<endl;
红色的地方一定要用指针的指针麽??? 谢谢!
}
using namespace std;
void sorted(int * ,int *);
void main()
{
int n;
cout<<" input N :"<<endl;
cin>>n;
int *number = new int[n];
sorted(number , &n);
}
void sorted(int *temp , int *m)
{
int swap;
for(int i=0 ; i <= *m ; i++)
{
if(*temp[i] <= *temp[i+1]);
{
swap = *temp[i+1];
*temp[i+1] = *temp[i];
*temp[i] = swap;
}
}
cout<<"the sorted number :"<<endl;
for(int j=0 ; j < *m ; j++)
{
cout<<*temp[j]<<" ";
}
cout<<endl;
红色的地方一定要用指针的指针麽??? 谢谢!
}
...全文
相关推荐
c++创建二维动态数组与内存释放问题
"C++ 创建二维动态数组与内存释放问题详解"C++ 创建二维动态数组是指在程序运行时动态地分配一个二维数组,以满足不同场景下的需求。然而,在使用二维动态数组时,内存释放问题也是需要特别注意的。
js中动态创建关联数组的问题
然而,JavaScript并没有一个直接的“关联数组”类型,而是通过对象实现的。这里我们将深入探讨在JavaScript中动态创建和操作关联数组的问题。
关于C++动态为二维数组分配空间的问题
### 关于C++动态为二维数组分配空间的问题在C++编程中,动态分配内存是一项非常重要的技能,尤其是在处理不确定大小的数据结构时。
树状数组(Binary Indexed Tree,BIT)高效地处理动态的区间求和问题
**动态规划:** 在某些动态规划问题中,树状数组可以用来优化状态转移过程,尤其是在需要频繁进行区间求和或更新的情况下。5.
Python背包问题动态规划求解(一维和二维数组).zip
动态规划是一种通过将复杂问题分解为子问题来求解的方法,适用于背包问题,因为它能够避免重复计算。一维数组动态规划解法:1.


