赞
踩
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include "stdio.h"
#include "stdlib.h"
#define N 10
#define S 10
void main()
{
int i,j,k,num[N],num1[S],flag = 1,temp;
randomize();
for(i = 0;i < N;i++)
{
num[i] = random(9000) + 1000;
flag = 1;
for(j = 2;j < num[i];j++)
{
if(num[i] % j == 0)
{
flag = 0;
break;
}
}
if(flag == 1)
{
printf("\nThe num is:%d\n",num[i]);
}
}
for(i = 0;i < S;i++)
{
if(flag == 1)
{
num1[i] = num[i];
}
printf("%d\t",num1[i]);
}
for(i = 1;i < S;i++)
for(k = 1;k <= S - i;i++)
if(num1[k-1] > num1[k])
{
temp = num1[k-1];
num1[k-1] = num1[k];
num1[k] = temp;
}
for(i = 0;i < S;i++)
printf("%d\t",num1[i]);
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。