题解 | #质数因子#
明明的随机数
http://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
//读入数据,分析处理数据,输出,三步走
#include<stdio.h>
#include<string.h>
int main()
{
int a[1001],b[1001];
int i = 0, j = 0, k = 0,cnt = 0;
int n,x;
char ch;
int temp;
while(scanf("%d",&n) == 1){
for(i = 0;i<n; i++){
scanf("%d",&x);
a[i] = x;
}
//读取一列数组放在a中
//将a中重复数字去掉,形成新的数列b
for(i = 0;i<n ;i++){
for(j = i+1;j<n; j++){
if(a[i]==a[j]){
for(k = j;k<n;k++){
a[k] = a[k+1];
}
n--;
j--;
}
}
}
//从小到大排序
for(i = 0;i<n; i++){
for(j = i+1; j< n ; j++){
if(a[i]> a[j]){
temp = a[i];
a[i]= a[j];
a[j] = temp;
}
}
}
//输出和置零
for(i = 0;i< n;i++)
printf("%d\n",a[i]);
for(i = 0;i<=n;i++)
a[i] = '\0';
}
return 0;
}
#include<string.h>
int main()
{
int a[1001],b[1001];
int i = 0, j = 0, k = 0,cnt = 0;
int n,x;
char ch;
int temp;
while(scanf("%d",&n) == 1){
for(i = 0;i<n; i++){
scanf("%d",&x);
a[i] = x;
}
//读取一列数组放在a中
//将a中重复数字去掉,形成新的数列b
for(i = 0;i<n ;i++){
for(j = i+1;j<n; j++){
if(a[i]==a[j]){
for(k = j;k<n;k++){
a[k] = a[k+1];
}
n--;
j--;
}
}
}
//从小到大排序
for(i = 0;i<n; i++){
for(j = i+1; j< n ; j++){
if(a[i]> a[j]){
temp = a[i];
a[i]= a[j];
a[j] = temp;
}
}
}
//输出和置零
for(i = 0;i< n;i++)
printf("%d\n",a[i]);
for(i = 0;i<=n;i++)
a[i] = '\0';
}
return 0;
}