![18bf1ca8e4797368ae7ef660306042c2.png](https://img-blog.csdnimg.cn/img_convert/18bf1ca8e4797368ae7ef660306042c2.png)
一.图形化窗口1. 图形窗口基本框架第1步 安装插件第2步 基本框架
#include<graphics.h>
#include<stdio.h>
intmain
{
//(width,height)
initgraph(640,450)
closegraph;
return0;
}2. 坐标系统
![21a86b7e5e9f1136736e49f452929f55.png](https://img-blog.csdnimg.cn/img_convert/21a86b7e5e9f1136736e49f452929f55.png)
二.文字输出1 .字符串输出
#include<graphics.h>
#include<stdio.h>
intmain
{
//(width,height)
initgraph(640,450);
//outextxy(x,y,"字符串")
outtextxy(100,100,"阿萨姆最帅");
getchar;
closegraph;
return0;
}2. 实数类输出
error C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
#define _CRT_SECURE_NO_WARNINGS
#define_CRT_SECURE_NO_WARNINGS
#include<graphics.h>
#include<stdio.h>
intmain
{
//(width,height)
initgraph(640,450);
//outextxy(x,y,"字符串")
//转换:实数类转换为字符串
charstr[20]="";
inti_number=1;
//printf
sprintf(str,"%d",i_number);
outtextxy(100,100,str);
getchar;
closegraph;
return0;
}
三.绘图函数--->五子棋
#include<graphics.h>
#include<stdio.h>
/*
贴图:int float double FILE
IMAGE1.定义一个照片变量
IMAGE MM;2.加载资源到变量
loadimage(&MM,"图片路径");3.贴图
putimage(int x,int y,&MM);
*/
intmain
{
initgraph(600,450);
IMAGEMM;
//函数调用
loadimage(&MM,"美女.jpg");
putimage(0,0,&MM);
getchar;
closegraph;
return0;
}
![48b6d2decba310c7319e4fcef9e01333.png](https://img-blog.csdnimg.cn/img_convert/48b6d2decba310c7319e4fcef9e01333.png)
#include<graphics.h>
#include<stdio.h>
intmain
{
initgraph(1023,548);
IMAGEbackground;
loadimage(&background,"gamebackground.jpg");
putimage(0,0,&background);
setlinecolor(BLACK);
for(inti=10;i<=530;i+=20)
{
line(10,i,530,i);
line(i,10,i,530);
}
//加粗
setlinestyle(PS_SOLID,4);
rectangle(10,10,530,530);
getchar;
closegraph;
return0;
}4.贴图函数--->学生管理系统
#include<graphics.h>
#include<stdio.h>
intmain
{
initgraph(600,400);
IMAGEbackground;
IMAGEmenu;
loadimage(&background,"bkimage.jpg",600,400);
loadimage(&menu,"image.jpg",200,50);
putimage(0,0,&background);
for(inti=0;i<4;i++)
{
putimage(200,80+i*50,&menu);
}
settextcolor(BLACK);
setbkmode(TRANSPARENT);
settextstyle(25,0,"黑体");
outtextxy(100,20,"阿萨姆的后宫管理系统 v1.0版本");
outtextxy(250,95,"xxxx");
outtextxy(250,145,"xxxxx");
outtextxy(250,195,"xxxxx");
outtextxy(250,245,"xxxxx");
getchar;
closegraph;
return0;
}
![298059ca0133aca400a2f76308554f3d.png](https://img-blog.csdnimg.cn/img_convert/298059ca0133aca400a2f76308554f3d.png)
5.鼠标操作--->鼠标位置MOUSEMSG 种类
![7c7de348132fae8243110fe008c308f3.png](https://img-blog.csdnimg.cn/img_convert/7c7de348132fae8243110fe008c308f3.png)
#define_CRT_SECURE_NO_WARNINGS
#include<graphics.h>
#include<stdio.h>
/*
鼠标:
定义鼠标变量:
MOUSEMSG m;
初始化鼠标消息变量
m=GetMouseMsg;
分类处理消息
if_else
switch(m.uMsg)
{
case WM_LBUTTONDOWN:
break;
case WM_RBUTTONDOWN:
break;
case WM_MOUSEMOVE:
break;
}
*/
intmain
{
initgraph(600,450);
while(1)
{
MOUSEMSGm=GetMouseMsg;
switch(m.uMsg)
{
caseWM_LBUTTONDOWN:
circle(m.x,m.y,4);
break;
caseWM_RBUTTONDOWN:
rectangle(m.x-4,m.y-4,m.x+4,m.y+4);
break;
caseWM_MOUSEMOVE:
charstr[20]="";
sprintf(str,"(%d,%d)",m.x,m.y);
outtextxy(0,0,str);
break;
}
}
closegraph;
return0;
}
习惯:
大学习惯:三个抄,抄作业,抄考试,抄毕业
--------
缺少思维,思考,弯路走的太少.没有培养自己的编程思维
错误:为什么很多同学从入门到放弃 从入门到入土,没有人给你解答,
好的习惯:坚持学习,让学习成为一种习惯(加效果图下面的交流群学习交流~有惊喜)