// ConsoleApplication8.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
int main()
{
int a[15];
int i, b, j, temp, k, n, m;
for (j = 0; j <= 14; j++){
printf("输入第%d个数\n", j + 1);
scanf_s("%d", &a[j]);
}
printf_s("输完了\n");
j = k = 0;
for (j = 0; j <= 14;j++){
for (k = 0; k <= 13; k++){
if (a[k]>=a[k+1]){
temp = a[k];
a[k] = a[k + 1];
a[k + 1] = temp;
}
}
}
printf_s("你输入的数从小到大排列是\n");
for (j = 0; j <= 14; j++){
printf_s("%d ", a[j]);
}
printf_s("输入你要查询的次数\n");
scanf_s("%d",&m);
for (j=1;j<=m;j++){
scanf_s("%d", &n);
b = 0;
for (i = 0; n >= a[i]; i++){
if (n == a[i]){
b = 1;
printf("是第%d个数\n", i+1);
}
}
if (b == 0){
printf("没有此数\n");
}
}
return main();
}
//
#include "stdafx.h"
int main()
{
int a[15];
int i, b, j, temp, k, n, m;
for (j = 0; j <= 14; j++){
printf("输入第%d个数\n", j + 1);
scanf_s("%d", &a[j]);
}
printf_s("输完了\n");
j = k = 0;
for (j = 0; j <= 14;j++){
for (k = 0; k <= 13; k++){
if (a[k]>=a[k+1]){
temp = a[k];
a[k] = a[k + 1];
a[k + 1] = temp;
}
}
}
printf_s("你输入的数从小到大排列是\n");
for (j = 0; j <= 14; j++){
printf_s("%d ", a[j]);
}
printf_s("输入你要查询的次数\n");
scanf_s("%d",&m);
for (j=1;j<=m;j++){
scanf_s("%d", &n);
b = 0;
for (i = 0; n >= a[i]; i++){
if (n == a[i]){
b = 1;
printf("是第%d个数\n", i+1);
}
}
if (b == 0){
printf("没有此数\n");
}
}
return main();
}