int main()
{int i,j,t,a[10]
for(i=0i<10i++) 世闹迅 //输入10个整数
弯袜 scanf("%d",&a[i])
for(i=0i<9i++) //降序冒泡排序
for(j=0j<9-ij++)
if(a[j]<a[j+1])
搜此 {t=a[j]a[j]=a[j+1]a[j+1]=t}
for(i=0i<10i++) //输出
printf("%d ",a[i])
printf("\n")
return 0
}
依次填——
i=0i<10i++
j=0j<兆渗9j++
x[j]<x[j+1]
x[j]=x[j+1] ——s=x[f]有错,应该是s=x[j]才对。
x[j+1]=s
代码另有3处错误:
printf('输入10个整数:\n")应改灶腊为printf("输入10个整数:\n")。
scanf("族辩脊%d"&x[i])应改为scanf("%d",&x[i])。
printf('%d",x[i])应改为printf("%d ",x[i])。
dim a(10) as integerdim i as integer,j as integer,k as intrger
private sub form_click()
text1=“”咐段毁
text2=“燃亩”
for i=1 to 10
a(i)=int(rnd*90+10)
text1=text1 &a(i)
next
end sub
private sub command1_click()
text2=“”衡备
for i=1 to 9
for j=10 to i+1 step -1
if a(j-1)>a(j) then
k=a(j-1)
a(j-1)=a(j)
a(j)=k
end if
next
next
for i=1 to 10
text2=text2 &a(i)
next
end sub
private sub command2_click()
dim min as integer
text2=“”
for i=1 to 9
k=i
for j=i+1 to 10
if a(k)>a(j) then k=j
next
min=a(i)
a(i)=a(k)
a(k)=min
next
for i=1 to 10
text2=text2 &a(i)
next
end sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)