#include <windows.h>//导入windows.h库
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM)//窗口过程
//窗口初始化(定义窗口的具体方式)
int WINAPI WinMain
(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
//int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevlnst, LPSTR lpsCmdLine, int nCmdShow)
{
HWND hwnd
MSG Msg
WNDCLASS wndclass
char lpszClassName[] = "窗口" //窗口类名
char lpszTitle[] = "HELLO!WORLD!" //My_Windows窗口标题名HELLO!WORLD!
wndclass.style = 0 //窗口风格
wndclass.hInstance = hInstance
wndclass.lpfnWndProc = WndProc //窗口过程函数地址
wndclass.cbClsExtra = 0 //窗口类无扩展
wndclass.cbWndExtra = 0//窗口实例无扩展
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION)
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW) //用箭头光标
wndclass.hbrBackground = (HBRUSH)(GetStockObject(WHITE_BRUSH)) //窗口背景色为白色
wndclass.lpszMenuName = NULL //窗口无菜单
wndclass.lpszClassName = lpszClassName//窗口类名为"窗口"
if(!RegisterClass(&wndclass)) //如果注册窗口类失败
{ MessageBeep(0)return FALSE}
hwnd = CreateWindow(
lpszClassName, //窗口类名
lpszTitle, //窗口实例的标题名
WS_OVERLAPPEDWINDOW, //窗口的风格
CW_USEDEFAULT,
CW_USEDEFAULT, //以上2行表示窗口宽李哪左上角坐标为默认值
CW_USEDEFAULT,
CW_USEDEFAULT, //以上2行表示窗口的高度和宽度为默认值
NULL, //此窗口无父窗口
NULL, //此窗口无主菜单
hInstance, //创建此窗口的应用程序的当前句柄(即进程)
NULL //不使用该值
)
ShowWindow(hwnd, nCmdShow)//显示窗口
UpdateWindow(hwnd) //绘制用户区(刷新用户区)
while(GetMessage(&Msg, NULL, 0, 0)) //消息循环
{
TranslateMessage(&Msg) //翻译消息
DispatchMessage(&Msg) //分发消息
}
return Msg.wParam //消息循环结束即程序结束将信息返回给系统
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0)
default:
return DefWindowProc(hwnd, message, wParam, lParam)
}
return 0
}
#include <stdio.h>int main() {
int i,j,L,W,a,b,dr,dc,rs,cs
int pLd,pWd,vLd,vWd// 板材长、宽方向余料尺寸
int parea,varea // 余料面积
int amount // 小料数量
int direction // 小料方向,长与L平行为0,垂直为1
char select[5]
FILE *fp
char filename[] = "data.txt"
if((fp = fopen(filename,"at")) == NULL) {
printf("\t无法打开数据文件:%s\n",filename)
return 1
}
while(1) {
printf("\t*** 板材下料助手 ***\n\n")
printf("\t1、输入板材及小料尺寸\n")
printf("\t2、显示下料信息\n")
printf("\t3、数据存盘\n")
printf("\t0、退出助手\n\n")
printf("\t请选择:")
scanf("%s",select)
switch(select[0]) {
case '1' :
printf("\t请输入板材及小料规格:")
while(scanf("%d%d%d%d",&L,&W,&a,&b) != 4)
printf("\t***** 非法数据!请重新输入:")
break
case '2' :
if(!(L && W && a && b)) {
printf("\t***** 缺少板材或小料规格数据。\n")
break
}
pLd = L % a, pWd = W % b// 平行方向下料
parea = L * pWd + W * pLd - pLd * pWd
vLd = L % b, vWd = W % a// 垂直方向下料
varea = L * vWd + W * vLd - vLd * vWd
if(parea > varea) { // 垂直下料更合理
direction = 1
dr = a, dc = b
rs = W / a, cs = L / b
}
else { // 水平下料更合理
direction = 0
dr = b, dc = a
rs = W / b, cs = L / a
}
amount = rs * cs
printf("\t板材规格:%d × %d\n",L,W)
printf("\t小料规格:%d × %d\n",a,b)
printf("\t小料数量:%d\n",amount)
printf("\t下料方向:%s\n",direction ? "垂行烂直" : "水平")
printf("\t余料面积:%d\n",direction ? varea : parea)
printf("\t使 用 率:%.0lf%%\n",100.0 * amount * a * b / L / W)
printf("\t小料位置数据:\n")
for(i = 0 i < 档岩漏rs * dr i += dr) {
for(j = 0 j < cs * dc j += dc)
printf("\t%d,%d\n",i,j)
}
printf("\n")
break
case '3' :
if(!(L && W && a && b)) {
printf("\t*****缺少板材及小料规格数据。\n")
break
}
fprintf(fp,"板材规格:%d × %d\n",L,W)
fprintf(fp,"小料规格:%d × %d\n",a,b)
fprintf(fp,"小料数量:%d\n",amount)
fprintf(fp,"下料方向:%s\n",direction ? "垂直" : "水平")
fprintf(fp,"余料面积:%d\n",direction ? varea : parea)
fprintf(fp,"使 用 率:%.0lf%%\n",100.0 * amount * a * b / L / W)
fprintf(fp,"小料位置数据:\n")
for(i = 0 i < rs * dr i += dr) {
for(j = 0 j < cs * dc j += dc)
fprintf(fp,"%d,%d\n",i,j)
}
fprintf(fp,"\n")
break
case '0' : fclose(fp) 枣郑return 0
}
}
fclose(fp)
return 0
}
到C:\WINDOWS\system32中找mspaint文件,如没有,到别人的XP中复制一个放入system32中,mspaint文件只有332K大逗指,一张软盘就可。如有,则在C:\Documents and Seyyings\All users\开始菜单迅指旅\程序\附件中建立快捷方式,目标指向C:WINDOWSsystem32中亩凳mspaint文件,则你的开始菜单程序附件中又有画图板了。欢迎分享,转载请注明来源:内存溢出
评论列表(0条)