#define IdYes 1002
#define IdNo 1003
#define IdStatic 1004
#define IdTimer 1005
#define Width 640
#define Height 480
#define Tick 2000
#include<windows.h>
int x,y
RECT rdesk
HINSTANCE hinst
HWND hyes,hno
BOOL quit=FALSE
LRESULT CALLBACK WndProc(HWND hwnd,UINT Message,WPARAM wParam,LPARAM lParam)
{
HDC hdc
PAINTSTRUCT ps
RECT rclient
HBRUSH hbrbkgnd
static COLORREF c
static BYTE r,g,b
switch(Message)
{
case WM_TIMER:
if(IdTimer==LOWORD(wParam))
{
r=(BYTE)(rand()%256)
g=(BYTE)(rand()%256)
b=(BYTE)(rand()%256)
c=RGB(r,g,b)
InvalidateRect(hwnd,NULL,TRUE)
UpdateWindow(hwnd)
}
break
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps)
hbrbkgnd=CreateSolidBrush(c)
SelectObject(hdc,hbrbkgnd)
GetClientRect(hwnd,&rclient)
FillRect(hdc,&rclient,hbrbkgnd)
DeleteObject(hbrbkgnd)
EndPaint(hwnd,&ps)
break
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IdYes:
quit=TRUE
MessageBox(hwnd,TEXT("回答正清型确,太答厅猜太伏余太好了!"),TEXT("宝贝"),MB_ICONEXCLAMATION|MB_OK)
SendMessage(hwnd,WM_CLOSE,0,0)
break
case IdNo:
MessageBox(hwnd,TEXT("回答错误哦,我很生气呢!"),TEXT("宝贝"),MB_ICONEXCLAMATION|MB_OK)
break
}
break
case WM_SIZE:
case WM_MOVE:
SetWindowPos(hwnd,HWND_TOPMOST,x,y,Width,Height,SWP_SHOWWINDOW)
break
case WM_DESTROY:
PostQuitMessage(0)
break
case WM_CLOSE:
if(quit)
{
KillTimer(hwnd,IdTimer)
DestroyWindow(hwnd)
}
break
case WM_CREATE:
CreateWindow(TEXT("Static"),
TEXT("请回答:做我女朋友好吗?"),
WS_CHILD|WS_VISIBLE|SS_CENTER,
200,
200,
240,
20,
hwnd,
(HMENU)IdStatic,
hinst,
NULL
)
hyes=CreateWindow(TEXT("Button"),
TEXT("好"),
WS_CHILD|WS_VISIBLE|BS_CENTER,
270,
230,
45,
20,
hwnd,
(HMENU)IdYes,
hinst,
NULL
)
hno=CreateWindow(TEXT("Button"),
TEXT("不好"),
WS_CHILD|WS_VISIBLE|BS_CENTER,
325,
230,
45,
20,
hwnd,
(HMENU)IdNo,
hinst,
NULL
)
SetTimer(hwnd,IdTimer,Tick,NULL)
break
default:
return DefWindowProc(hwnd,Message,wParam,lParam)
}
return 0
}
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
WNDCLASSEX wc
HWND hwnd
MSG msg
hinst=hInstance
srand(time(NULL))
memset(&wc,0,sizeof(wc))
wc.cbSize=sizeof(WNDCLASSEX)
wc.lpfnWndProc=WndProc
wc.hInstance=hInstance
wc.hCursor=LoadCursor(NULL,IDC_ARROW)
wc.hbrBackground=(HBRUSH)(COLOR_WINDOW+1)
wc.lpszClassName=TEXT("WindowClass")
wc.hIcon=LoadIcon(NULL,IDI_APPLICATION)
wc.hIconSm=LoadIcon(NULL,IDI_APPLICATION)
if(!RegisterClassEx(&wc))
{
MessageBox(NULL,TEXT("窗口注册失败!"),TEXT("错误"),MB_ICONEXCLAMATION|MB_OK)
return 0
}
GetWindowRect(GetDesktopWindow(),&rdesk)
x=(rdesk.right-Width)/2
y=(rdesk.bottom-Height)/2,
hwnd = CreateWindowEx(WS_EX_TOPMOST,
TEXT("WindowClass"),
TEXT("I Love You"),
WS_THICKFRAME|WS_VISIBLE,
x,
y,
Width,
Height,
NULL,NULL,hInstance,NULL)
if(NULL==hwnd)
{
MessageBox(NULL,TEXT("窗口创建失败!"),TEXT("错误!"),MB_ICONEXCLAMATION|MB_OK)
return 0
}
while(GetMessage(&msg,NULL,0,0)>0)
{
TranslateMessage(&msg)
DispatchMessage(&msg)
}
return msg.wParam
}
截图
这个算是技术宅的段子吧
从风格上看,很可御野碰能是宅男写的 而不是女生
#include "stdio.h" //谭老说:include<> 和""都是合法的。<>这位标准方式,在头文件目录下寻找。#include "stdlib.h" //""现在当前目录下找,若无,则在头文件目录下找。一般:库函数→<>自编头文件→""
result love(boy, girl)
{
if ( boy.有房() and boy.有车() )
{
boy.set(nothing)
脊团 return girl.嫁给(boy)
}
if ( girl.愿意等() )
{
while( ! (boy.赚钱 > 100,000 and girl.感情 > 8 ) )
{
for ( day=1 day <=365 day++)
{
if ( day == 情人节 )
if ( boy.givegirl(玫瑰) )
girl.感情++
else
girl.感情--
if( day == girl.生日)
if ( boy.givegirl(玫瑰) )
girl.感情++
else
girl.感情--
boy.拼命赚钱()
}
}
镇谈 if ( boy.有房() and boy.有车() )
{
boy.set(nothing)
return girl.嫁给(boy)
}
年龄++
girl.感情--
}
return girl.goto( another_boy)
}
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define I 20
#define R 340
#include <string.h>
int main()
{
char answer[10]
printf("遇到你\n我才发现\n曾经所有的条件\n似乎都成了我等你的借口\n\n")
printf("我对你的感情已经决堤\n所以\n请允许我,从今往后映入你\n明媚的眼\n")
printf("我\n想和你\n耳鬓厮磨,相濡以沫!")
printf("答应我吧!\n输入yes,你可以看到我的真心\n")
scanf("%s", answer)
float y, x, z, f
for (y = 1.5fy >-1.5fy -= 0.1f)
{
for (x = -1.5fx <1.5fx += 0.05f)
{
z = x * x + y * y - 1
f = z * z*z - x * x*y*y*y
putchar(f <差悉= 0.0f ? "*********"[(int)(f*-8.0f)] : ' ')
}
putchar('\n')
}
long time
for ()
{
system("color a")
for (time = 0time<99999999time++)
system("color b")
for (time = 0time<99999999time++)
system("color c")
for (time = 0time<99999999time++)
system("color d")
for (time = 0time<99999999time++)
system("color e")
for (time = 0time<99999999time++)
system("color f")
for (time = 0time<99999999time++)
system("color 0")
for (time = 0time<99999999time++)
system("color 1")
for (time = 0time<99999999time++)
system("color 2")
for (time = 0time<99999999time++)
system("color 3")
for (time = 0time<99999999time++)
system("color 4")
for (time = 0time<99999999time++)
system("color 5")
for (time = 0time<99999999time++)
system("color 6")
for (time = 0time<99999999time++)
system("color 7")
for (time = 0time<99999999time++)
system("color 8")
for (time = 0time<99999999time++)
system("color 9")
}
getchar()
return 0
}
运行效果:
扩展资料:printf函数使用注意事项
1、域宽
%d:按整型数据的实际长度输出。
如果想输出指定宽度可以指定域宽,%md--&gt;m域宽,打印出来以后,在控制台上,显示m位;
如果我们要打印的数的位数如果超过我们设定m则原样输出;
如果我们要打印的数的位数如果小于我们设定的位数,则补空白,具体如下:
如果m为正数,则左对齐(左侧补空白);
如果m为负数,则右对齐(右侧补空白)。
2、转义则庆没字符
如果想输出字符"%",则应该在“格式控制”字符串中用连续两个%表示。
如:printf("%f%%",1.孙纳0/3);输出结果:0.333333%。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)