rose.c

来自「Many C samples. It is a good sample for 」· C语言 代码 · 共 37 行

C
37
字号
/* Bai tap 2_8 - Chuong trinh ve duong Hoa hong */
#include <conio.h>
#include <graphics.h>
#include <math.h>

#define K 150

void rose(int n)
{
   double goc = 0.0;
   double f, xc, yc;

   if (n % 2 == 0)
     n /= 2;
   xc = getmaxx() / 2;
   yc = getmaxy() / 2;
   while (!kbhit())
   {
      f = K * cos(goc * n);
      putpixel(xc + f * cos(goc), yc + f * sin(goc), YELLOW);
      goc += 0.01;
   }
}

void main()
{
  int gr_drive = DETECT, gr_mode;
  int n;

  printf("\nCho biet so canh hoa : ");
  scanf("%d", &n);
  initgraph(&gr_drive, &gr_mode, "");
  rose(n);

  getch();
  closegraph();
}

⌨️ 快捷键说明

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