请看一上这个输出该加在什么地方
请看一下这个输出该加在什么地方
#include "stdafx.h"
#include <iostream>
using namespace std;
void sort(int *pArray, int num)
{
int i = 0;
int j = 0;
for(i=0; i<num; i++)
{
for(j=0; j<num-i-1; j++)
{
int temp;
if(*(pArray+i) < *(pArray+j+1))
{
temp = *(pArray+i);
*(pArray+j) = *(pArray+j+1);
*(pArray+j+1) = temp;
}
}
}
}
int main(int argc, char* argv[])
{
int nVal[] = {5,2,8,3,9,1,7,4,6,0};
sort(nVal, 10);
system("pause");
return 0;
}
------解决方案--------------------
看你的需要了,如果没有特殊要求的话,加在哪里都是可以的
------解决方案--------------------
------解决方案--------------------
int main(int argc, char* argv[])
{
int nVal[] = {5,2,8,3,9,1,7,4,6,0};
sort(nVal, 10);
for(size_t i = 0; i!=10; ++i){
cout<<nVal[i] << ", ";
cout << endl;
}
system("pause");
return 0;
}
#include "stdafx.h"
#include <iostream>
using namespace std;
void sort(int *pArray, int num)
{
int i = 0;
int j = 0;
for(i=0; i<num; i++)
{
for(j=0; j<num-i-1; j++)
{
int temp;
if(*(pArray+i) < *(pArray+j+1))
{
temp = *(pArray+i);
*(pArray+j) = *(pArray+j+1);
*(pArray+j+1) = temp;
}
}
}
}
int main(int argc, char* argv[])
{
int nVal[] = {5,2,8,3,9,1,7,4,6,0};
sort(nVal, 10);
system("pause");
return 0;
}
------解决方案--------------------
看你的需要了,如果没有特殊要求的话,加在哪里都是可以的
------解决方案--------------------
int main(int argc, char* argv[])
{
int nVal[] = {5,2,8,3,9,1,7,4,6,0};
sort(nVal, 10);
for(size i = 0; i!=10; ++i){
std::cout<<nVal[i];
}
system("pause");
return 0;
}
------解决方案--------------------
int main(int argc, char* argv[])
{
int nVal[] = {5,2,8,3,9,1,7,4,6,0};
sort(nVal, 10);
for(size_t i = 0; i!=10; ++i){
cout<<nVal[i] << ", ";
cout << endl;
}
system("pause");
return 0;
}