Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <unistd.h>
- using namespace std;
- int main() {
- int N=21, x0=5, y0=5, s=100, r=4;
- int vx = 1, vy = 5 ;
- char c = 'a';
- for (int t=0; t<=s; t++){
- for (int i=0; i<=N; i++) {
- for (int j=0; j<=N; j++) {
- int d2=(j-x0)*(j-x0)+(i-y0)*(i-y0);
- if (d2<=r*r) {
- cout<< c <<" ";
- }
- else if (i==0 || i==N || j==0 || j==N){
- cout<<"* ";
- }
- else {
- cout<<" ";
- }
- }
- cout<<endl;
- }
- x0 += vx;
- y0 += vy;
- if (x0 + r >= N - 1) {
- vx = -vx;
- //int circle_r = x0 + r;
- //int field_r = N - 1;
- //int d = circle_r - field_r;
- x0 = N - 1 - r;
- //x0 -= d;
- }
- if (y0 + r >= N - 1) {
- vy = -vy;
- //int circle_b = y0 + r;
- //int field_b = N - 1;
- //int d = circle_b - field_b;
- y0 = N - 1 - r;
- //y0 -= d;
- }
- if (x0 - r <= 0) {
- vx = -vx;
- x0 = r + 1;
- //x0 -= x0 - r - 1;
- }
- if (y0 - r <= 0) {
- vy = -vy;
- //int circle_t = y0 - r;
- //int field_t = 0;
- //int d = circle_t - field_t;
- y0 = r + 1;
- //y0 -= d - 1;
- }
- c = (c + 1)%10 + 'a';
- cout << "\033[u";
- sleep(1);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement