顶了,code 我拷走了
留着慢慢研究
留着慢慢研究
#include <stdio.h> #define yn 10 #define xn 5 void qk(int y) { int i; while(y!=yn) { for(i=5;i<=50;i+=5) { gotoxy(i,y); putch(' '); } if(y==yn-3||y==yn+3)break; if(y<yn)y++; else y--; } } int main(void) { int a[10] = {3,2,1,5,7,4,6,9,8,2}; int x,y,i,j,temp,xx,yy; clrscr(); gotoxy(1,yn); for(i=0;i<10;i++) printf("%*d",xn,a[i]); sleep(1); for (x = 0; x < 10; x++) { qk(yn-2); gotoxy(xn*(x+1),8); putch('x'); gotoxy(xn*(x+1),9); putch(25); for (y = 0; y < 10; y++) { sleep(1); qk(yn+2); gotoxy(xn*(y+1),11); putch(24); gotoxy(xn*(y+1),12); putch('y'); if(a[x] > a[y]) { sleep(1); gotoxy(xn*(x+1),yn); putch(' '); gotoxy(xn*(x+1),yn-3); putch(a[x]+48); gotoxy(xn*(y+1),yn); putch(' '); gotoxy(xn*(y+1),yn+3); putch(a[y]+48); for(i=xn*(x+1)+1,j=xn*(y+1)-1;i<=xn*(y+1);i++,j--) { sleep(1); gotoxy(i-1,yn-3); putch(' '); gotoxy(i,yn-3); putch(a[x]+48); gotoxy(j+1,yn+3); putch(' '); gotoxy(j,yn+3); putch(a[y]+48); } sleep(1); qk(yn-3); qk(yn+3); gotoxy(xn*(x+1),yn); putch(a[y]+48); gotoxy(xn*(y+1),yn); putch(a[x]+48); temp = a[y]; a[y] = a[x]; a[x] = temp; } } } getch(); }