首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> C語言 >> C >> C 語言實例練習

C語言練習實例58:TC繪製同心矩形與圓

     編輯:C 語言實例練習

C語言練習實例58:TC繪製同心矩形與圓

本實例使用 rectangle 繪製一組同心矩形,並添加文字、分隔線和外接圓。

源代碼

// Created by www.runoob.com on 15/11/9.
// Copyright © 2015年 菜鳥教程. All rights reserved.
//
#include "graphics.h"

int main() {
    int x0, y0, y1, x1, driver, mode, i;
    driver = VGA; mode = VGAHI;
    initgraph(&driver, &mode, "");
    setbkcolor(YELLOW);
    x0 = 263; y0 = 263; y1 = 275; x1 = 275;
    for (i = 0; i <= 18; i++) {
        setcolor(1);
        rectangle(x0, y0, x1, y1);
        x0 -= 5; y0 -= 5; x1 += 5; y1 += 5;
    }
    settextstyle(DEFAULT_FONT, HORIZ_DIR, 2);
    outtextxy(150, 40, "How beautiful it is!");
    line(130, 60, 480, 60);
    setcolor(2);
    circle(269, 269, 137);
}

效果

黃色背景上,藍色同心矩形向外擴展,紅色文字、白色分隔線、綠色大圓構成裝飾畫面。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved