cocos 游戏开发 (第一天作业)

时间:2023-11-11 23:35:38

作业1——控制台游戏菜单

 // 游戏菜单.cpp : 定义控制台应用程序的入口点。
// #include "stdafx.h"
#include<iostream>
#include"windows.h"
#define KEY_DOWN(vk_code) (GetAsyncKeyState(vk_code)&0x8000?1:0) using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int nKeyState = ;
while (true)
{
system("CLS"); if (KEY_DOWN(VK_DOWN))
{
nKeyState = abs(++nKeyState % );
}
if (KEY_DOWN(VK_UP))
{
--nKeyState;
if (nKeyState < )
{
nKeyState = ;
} } cout << "■■■■■■■■■■■■" << endl;
cout << "■■■■■■■■■■■■" << endl;
if (nKeyState == )
{
cout << "■■ >-开始游戏 ■■" << endl;
cout << "■■ 游戏设置 ■■" << endl;
cout << "■■ 结束游戏 ■■" << endl; }
else if (nKeyState == )
{
cout << "■■ 开始游戏 ■■" << endl;
cout << "■■ >-游戏设置 ■■" << endl;
cout << "■■ 结束游戏 ■■" << endl;
}
else if (nKeyState == )
{
cout << "■■ 开始游戏 ■■" << endl;
cout << "■■ 游戏设置 ■■" << endl;
cout << "■■ >-结束游戏 ■■" << endl;
}
cout << "■■■■■■■■■■■■" << endl;
cout << "■■■■■■■■■■■■" << endl; }
return ;
}

游戏菜单

作业2——1+(1+2)+(1+2+3)+(...)+...+..

 // 作业2.cpp : 定义控制台应用程序的入口点。
// #include "stdafx.h"
#include<iostream>
#include"Windows.h" using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{ int a = ;
int b = ;
int c = ;
int sum = ; int i = ;
cout << "请输入一个整数" << endl;
cin >> i;
for (a; a<=i; a++)
{
for (b; b<=a; b++)
{
c += b;
}
sum += c;
}
cout << sum << endl;
system("pause"); return ;
}

累加

作业三——数字逆序

 // 作业3.cpp : 定义控制台应用程序的入口点。
// #include "stdafx.h"
#include<iostream>
#include"Windows.h" using namespace std; int _tmain(int argc, _TCHAR* argv[])
{ int i;
int len;
char str[]; cout << "请输入要操作的数字" << endl;
cin >> str;
len = strlen(str);
for (i = len - ; i >= ; i--)
{
cout << str[i];
}
cout << endl; system("pause"); return ; }

数字逆序