⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 epitro.c

📁 Many C samples. It is a good sample for students to learn C language.
💻 C
字号:
/* Bai tap 2_10 - Chuong trinh ve duong Epitrochoid */
#include <conio.h>
#include <graphics.h>
#include <math.h>

double _X(double a, double b, double k, double t)
{
  return (a + b) * cos(2 * M_PI * t) -
         k * cos(2 * M_PI * (a+b) * t / b);
}

double _Y(double a, double b, double k, double t)
{
  return (a + b) * sin(2 * M_PI * t) -
         k * sin(2 * M_PI * (a+b) * t / b);
}

void epitro(double a, double b, double k)
{
   double t = 0.0;
   double f, xc, yc, x, y;

   xc = getmaxx() / 2;
   yc = getmaxy() / 2;
   while (!kbhit())
   {
      x = _X(a, b, k, t);
      y = _Y(a, b, k, t);
      putpixel(xc + x, yc + y, YELLOW);
      t += 0.001;
   }
}

void main()
{
  int gr_drive = DETECT, gr_mode;
  double a, b, k;

  printf("\nCho biet ban kinh a : ");
  scanf("%lf", &a);
  printf("\nCho biet ban kinh b : ");
  scanf("%lf", &b);
  printf("\nCho biet ban kinh k : ");
  scanf("%lf", &k);
  initgraph(&gr_drive, &gr_mode, "");
  epitro(a, b, k);

  getch();
  closegraph();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -