锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
void
聽move(
int
聽number,
char
聽from,
char
聽rely,
char
聽to)
{
聽聽聽聽
if
(number聽
==
聽
1
)
聽聽聽聽
{
聽聽聽聽聽聽聽聽printf(
"
Move聽a聽disk聽from聽%c聽to聽%c\n
"
,from,to);
聽聽聽聽聽聽聽聽
return
;
聽聽聽聽}
聽聽聽聽move(number
-
1
,from,to,rely);
聽聽聽聽move(
1
,from,rely,to);
聽聽聽聽move(number
-
1
,rely,from,to);
}
int
聽_tmain(
int
聽argc,聽_TCHAR
*
聽argv[])
{
聽聽聽聽move(
3
,
'
A
'
,
'
B
'
,
'
C
'
);
聽聽聽聽::system(
"
pause
"
);
聽聽聽聽
return
聽
0
;
}
聽
聽
int
聽A[
10
]
=
{
1
,
2
,
5
,
7
,
3
,
14
,
78
,
25
,
11
,
14
}
;
void
聽InsertSort(
int
聽a[],
int
聽size)
{
聽聽聽聽
for
(
int
聽i
=
1
;聽i
<
size;聽i
++
)
聽聽聽聽
{
聽聽聽聽聽聽聽聽
int
聽key
=
a[i];
聽聽聽聽聽聽聽聽
int
聽j
=
i
-
1
;
聽聽聽聽聽聽聽聽
while
(a[j]
>
key聽
&&
聽j
>=
0
)
聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽a[j
+
1
]
=
a[j];
聽聽聽聽聽聽聽聽聽聽聽聽j
--
;
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽a[j
+
1
]
=
key;
聽聽聽聽}
}
int
聽_tmain(
int
聽argc,聽_TCHAR
*
聽argv[])
{
聽聽聽聽InsertSort(A,
sizeof
(A)
/
sizeof
(A[
0
]));
聽聽聽聽
for
(
int
聽i
=
0
;聽i
<
10
;聽i
++
)
聽聽聽聽
{
聽聽聽聽聽聽聽聽printf(
"
%d\n
"
,A[i]);
聽聽聽聽}
聽聽聽聽::system(
"
pause
"
);
聽聽聽聽
return
聽
0
;
}
#include聽
"
SDL.h
"
#include聽
"
SDL_ttf.h
"
SDL_Surface聽
*
screen
=
NULL;
TTF_Font聽
*
font
=
NULL;
//
screen聽to聽show聽on聽window
const
聽
int
聽SCREEN_BPP
=
32
;


int
聽main(聽
int
聽argc,聽
char
*
聽args[]聽)
{
聽聽聽聽
//
Start聽SDL
聽聽聽聽
bool
聽quit
=
false
;
聽聽聽聽SDL_Rect聽rectLeft;
聽聽聽聽SDL_Rect聽rectRight;
聽聽聽聽rectLeft.x
=
0
;
聽聽聽聽rectLeft.y
=
0
;
聽聽聽聽rectLeft.w
=
320
;
聽聽聽聽rectLeft.h
=
480
;
聽聽聽聽rectRight.x
=
320
;
聽聽聽聽rectRight.y
=
0
;
聽聽聽聽rectRight.w
=
640
;
聽聽聽聽rectRight.h
=
480
;
聽聽聽聽SDL_Init(聽SDL_INIT_EVERYTHING聽);
聽聽聽聽
if
(TTF_Init()
==-
1
)
聽聽聽聽聽聽聽聽
return
聽
false
;
聽聽聽聽
聽聽聽聽screen聽
=
聽SDL_SetVideoMode(聽
600
,聽
480
,聽SCREEN_BPP,聽SDL_SWSURFACE聽);
聽聽聽聽
if
(screen
==
NULL)
聽聽聽聽聽聽聽聽
return
聽
false
;
聽聽聽聽Uint32聽colorBlue
=
SDL_MapRGB(screen
->
format,
0
,
0
,
255
);
聽聽聽聽Uint32聽colorGreen
=
SDL_MapRGB(screen
->
format,
0
,
255
,
0
);
聽聽聽聽Uint32聽colorRed
=
SDL_MapRGB(screen
->
format,
255
,
0
,
0
);
聽聽聽聽Uint32聽colorBlack
=
SDL_MapRGB(screen
->
format,
0
,
0
,
0
);
聽聽聽聽SDL_Event聽
event
;
聽聽聽聽
while
(
!
quit)
聽聽聽聽
{
聽聽聽聽聽聽聽聽
if
(SDL_PollEvent(
&
event
))
聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽
if
(
event
.type聽
==
聽SDL_MOUSEMOTION)
聽聽聽聽聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽Uint16聽x
=
event
.motion.x;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽Uint16聽y
=
event
.motion.y;

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if
(x
>
0
聽
&&
聽x
<
320
聽
&&
聽y
>
0
聽
&&
聽y
<
480
聽)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽SDL_FillRect(screen,
&
rectLeft,colorBlue);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽SDL_FillRect(screen,
&
rectRight,colorBlack);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if
(x
>
320
聽
&&
聽x
<
640
聽
&&
聽y
>
0
聽
&&
聽y
<
480
聽)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽SDL_FillRect(screen,
&
rectRight,colorGreen);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽SDL_FillRect(screen,
&
rectLeft,colorBlack);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽
if
(
event
.type聽
==
SDL_MOUSEBUTTONDOWN)
聽聽聽聽聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽Uint16聽x
=
event
.motion.x;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽Uint16聽y
=
event
.motion.y;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if
(
event
.button.button聽
==
聽SDL_BUTTON_LEFT)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if
(x
>
0
聽
&&
聽x
<
320
聽
&&
聽y
>
0
聽
&&
聽y
<
480
聽)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽SDL_FillRect(screen,
&
rectLeft,colorRed);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if
(x
>
320
聽
&&
聽x
<
640
聽
&&
聽y
>
0
聽
&&
聽y
<
480
聽)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽SDL_FillRect(screen,
&
rectRight,colorRed);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽
if
(
event
.type聽
==
聽SDL_QUIT)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽quit
=
true
;
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
if
(SDL_Flip(screen)聽
==
聽
-
1
)
聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽
return
聽
false
;
聽聽聽聽聽聽聽聽}
聽聽聽聽}
聽聽聽聽SDL_FreeSurface(screen);
聽聽聽聽SDL_Quit();
聽聽聽聽
return
聽
0
;聽聽聽聽
}
#include聽"SDL.h"
#include聽"SDL_ttf.h"
SDL_Surface聽*screen=NULL;
SDL_Surface聽*up=NULL;
SDL_Surface聽*down=NULL;
SDL_Surface聽*left=NULL;
SDL_Surface聽*right=NULL;
SDL_Surface聽*message=NULL;
TTF_Font聽*font=NULL;
//screen聽to聽show聽on聽window
const聽int聽SCREEN_BPP=32;
SDL_Color聽textColor=
{255,255,255};

int聽main(聽int聽argc,聽char*聽args[]聽)

{
聽聽聽聽//Start聽SDL
聽聽聽聽bool聽quit=false;
聽聽聽聽SDL_Init(聽SDL_INIT_EVERYTHING聽);
聽聽聽聽if(TTF_Init()==-1)
聽聽聽聽聽聽聽聽return聽false;
聽聽聽聽screen聽=聽SDL_SetVideoMode(聽600,聽480,聽SCREEN_BPP,聽SDL_SWSURFACE聽);
聽聽聽聽if(screen==NULL)
聽聽聽聽聽聽聽聽return聽false;
聽聽聽聽font=TTF_OpenFont("tahoma.ttf",28);
聽聽聽聽up聽=聽TTF_RenderText_Solid(聽font,聽"Up聽was聽pressed.",聽textColor聽);
聽聽聽聽down聽=聽TTF_RenderText_Solid(聽font,聽"Down聽was聽pressed.",聽textColor聽);
聽聽聽聽left聽=聽TTF_RenderText_Solid(聽font,聽"Left聽was聽pressed",聽textColor聽);
聽聽聽聽right聽=聽TTF_RenderText_Solid(聽font,聽"Right聽was聽pressed",聽textColor聽);
聽聽聽聽SDL_Event聽event;
聽聽聽聽while(!quit)
聽聽聽聽
{
聽聽聽聽聽聽聽聽if(SDL_PollEvent(&event))
聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽if(event.type聽==聽SDL_KEYDOWN)
聽聽聽聽聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽switch(event.key.keysym.sym)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽case聽SDLK_UP:聽message=up;break;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽case聽SDLK_DOWN:聽message=down;break;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽case聽SDLK_LEFT:聽message=left;break;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽case聽SDLK_RIGHT:聽message=right;break;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽if(event.type聽==聽SDL_QUIT)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽quit=true;
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽if(message聽!=聽NULL)
聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽Uint32聽colorVal=SDL_MapRGB(screen->format,0,0,0);
聽聽聽聽聽聽聽聽聽聽聽聽SDL_FillRect(screen,聽&screen->clip_rect,colorVal);
聽聽聽聽聽聽聽聽聽聽聽聽SDL_BlitSurface(message,NULL,screen,NULL);
聽聽聽聽聽聽聽聽聽聽聽聽message=NULL;
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽if(SDL_Flip(screen)聽==聽-1)
聽聽聽聽聽聽聽聽
{
聽聽聽聽聽聽聽聽聽聽聽聽return聽false;
聽聽聽聽聽聽聽聽}
聽聽聽聽}
聽聽聽聽//Quit聽SDL
聽聽聽聽SDL_Quit();
聽聽聽聽return聽0;聽聽聽聽
}

int
聽_tmain(
int
聽argc,聽_TCHAR
*
聽argv[])
{
聽
char
聽str1[]聽聽聽聽聽聽聽
=
聽
"
abc
"
;
聽
char
聽str2[]聽聽聽聽聽聽聽
=
聽
"
abc
"
;
聽
const
聽
char
聽str3[]聽
=
聽
"
abc
"
;聽
聽
const
聽
char
聽str4[]聽
=
聽
"
abc
"
;聽
聽
const
聽
char
*
聽str5聽聽
=
聽
"
abc
"
;
聽
const
聽
char
*
聽str6聽聽
=
聽
"
abc
"
;
聽cout
<<
(str1
==
str2)
<<
"
\n
"
;
聽cout
<<
(str3
==
str4)
<<
"
\n
"
;
聽cout
<<
(str5
==
str6)
<<
"
\n
"
;
聽::system(
"
pause
"
);
聽
return
聽
0
;
}