#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include "graphics.h"
#include "genlib.h"
#include "conio.h"
#include <windows.h>
#include <olectl.h>
#include <stdio.h>
#include <mmsystem.h>
#include <wingdi.h>
#include <ole2.h>
#include <ocidl.h>
#include <winuser.h>
#define houseHeight 3.0
#define houseWidth 2.0
#define atticHeight 1.0
#define Height 0.3
#define Width 0.4
void DrawHouse(double x, double y);
void DrawOutline(double x, double y);
void DrawBox(double x, double y, double width, double height);
void DrawGrid(double x, double y, double width, double height,
int columns, int rows);
void Drawdoor(double x, double y, double n);
void DrawTriangle(double x, double y, double base, double height);
void Main()
{
double cx, cy;
InitGraphics();
cx = GetWindowWidth() / 2;
cy = GetWindowHeight() / 2;
DrawHouse(cx - 2*houseWidth,
cy - houseHeight);
}
void DrawHouse(double x, double y){
DrawGrid( x, y, houseWidth, houseHeight, 4.0, 2.0);
DrawTriangle( x, y, houseWidth, atticHeight);
DrawTriangle( x+3*houseWidth, y, houseWidth, atticHeight);
double s=x+houseWidth;
Drawdoor( s, y, Width, Height, 6);
}
void Drawdoor(double x, double y,double width, double height, double n){
int i;
for(i=1;i<=n;i++){
DrawBox(x, y, width, height);
x=x+2*Width;
}
}
void DrawGrid(double x, double y, double width, double height,
int columns, int rows)
{
int i, j;
for (i = 0; i < columns; i++) {
for (j = 0; j < rows; j++) {
DrawBox(x + i * width, y + j * height,
width, height);
}
}
}
void DrawBox(double x, double y, double width, double height)
{
MovePen(x, y);
DrawLine(0, height);
DrawLine(width, 0);
DrawLine(0, -height);
DrawLine(-width, 0);
}
void DrawTriangle(double x, double y, double base, double height)
{
MovePen(x, y);
DrawLine(base, 0);
DrawLine(-base / 2, height);
DrawLine(-base / 2, -height);
}
我的图
原图
https://img-mid.csdnimg.cn/release/static/image/mid/ask/600467070156150.png "#left")