Efekt z C++, zadanko z programowania. Ramka powiększa się do zadanych wymiarów.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | #include <stdlib .h> #include <stdio .h> #include <iostream> #define MAX 128 using namespace std; int gotoxy(int x, int y) { char essq[MAX]={0}; sprintf(essq, "\033[%d;%df", y,x); printf("%s", essq); return 0; } void draw(int x1,int y1,int x2,int y2,char z) { int i; for (i=x1; i< =x2; i++) { gotoxy(i,y1); cout<<z; gotoxy(i,y2); cout<<z; } for (i=y1+1; i<y2; i++) { gotoxy(x1,i); cout<<z; gotoxy(x2,i); cout<<z; } } void boom(int x1,int y1,int x2,int y2,char z) { int x,y,m=0,n=0; ((x1+x2)%2) ? x=((x1+x2)/2)+1 : x=(x1+x2)/2 ; ((y1+y2)%2) ? y=((y1+y2)/2)+1 : y=(y1+y2)/2 ; int i=x,j=y; do { system("clear"); if(i<=x2) { m++; i++; } if(j<=y2) { n++; j++; } draw(x-m,y-n,x+m,y+n,z); getchar(); }while((i<=x2) || (j<=y2)); } int main() { int x1=10, x2=40, y1=10,y2=40; char z='o'; boom(x1,y1,x2,y2,z); cout<<endl; } |


Wpisy (RSS)