C++让计算机产生10个随机数并让其按大小排序输出#include #include using namespace std;int getRand(){static int ctrl = 0;if(!ctrl){srand((unsigned)time(0));ctrl++;}return rand()%31+1;}int main(){int a[6] = {0};int num = 0;for(int i=0;
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/24 12:08:33
C++让计算机产生10个随机数并让其按大小排序输出#include #include using namespace std;int getRand(){static int ctrl = 0;if(!ctrl){srand((unsigned)time(0));ctrl++;}return rand()%31+1;}int main(){int a[6] = {0};int num = 0;for(int i=0;
C++让计算机产生10个随机数并让其按大小排序输出
#include
#include
using namespace std;
int getRand()
{
static int ctrl = 0;
if(!ctrl)
{
srand((unsigned)time(0));
ctrl++;
}
return rand()%31+1;
}
int main()
{
int a[6] = {0};
int num = 0;
for(int i=0;i
C++让计算机产生10个随机数并让其按大小排序输出#include #include using namespace std;int getRand(){static int ctrl = 0;if(!ctrl){srand((unsigned)time(0));ctrl++;}return rand()%31+1;}int main(){int a[6] = {0};int num = 0;for(int i=0;
已经把排序的具体步骤加到你的程序里了!你自己看看吧!
#include
#include
using namespace std;
int getRand()
{
static int ctrl = 0;
if(!ctrl)
{
srand((unsigned)time(0));
ctrl++;
}
return rand()%31+1;
}
int main()
{
int a[6] = {0};
int num = 0;
int t;
for(int i=0;i=0;i--) //排序的具体步骤
{ for(int j=0;ja[j+1])
{t=a[j+1];a[j+1]=a[j];a[j]=t;}
}
}
for(int i=0;i