#define N 1001
void bubblesort(int *list,int len) //冒泡排序
{
int i,j
int temp
for(i=0i<len - 1i++)
for(j=0j<len-i - 1j++)
{
if(list[j+1]<list[j])
{
temp=list[j+1]
list[j+1]=list[j]
list[j]=temp
}
}
}
int main(){
int num
int tar[N]
scanf("%d", &num)
while(num != 0){
for(int i = 0 i< num i++){
scanf("%d", &tar[i])
}
bubblesort(tar, num)
if(num % 2 == 0){
printf("%lg\n",(tar[num/2] + tar[num/2 - 1]) / 2.0)
}else{
printf("%lg\n", tar[num/2]*1.0)
}
scanf("%d",&num)
}
return 0
}
没有包含头文件conio.h,还有倒数第三行改为printf("%d\n",zws(a,b,c))
#include<conio.h>
#include<stdio.h>
int zws(int a, int b, int c){
int ans
if (a >= b &&a <= c) ans = a
if (a <= b &&a >= c) ans = a
if (b >= a &&b <= c) ans = b
if (b <= a &&b >= c) ans = b
if (c >= a &&c <= b) ans = c
if (c <= a &&c >= b) ans = c
return ans
}
int main()
{
int a, b, c
printf("please input 3 integar:")
scanf("%d %d %d", &a, &b, &c)
printf("%d\n",zws(a, b, c))
getch()
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)