zoukankan      html  css  js  c++  java
  • cocos 游戏开发 (第一天作业)

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

     1 // 游戏菜单.cpp : 定义控制台应用程序的入口点。
     2 //
     3 
     4 #include "stdafx.h"
     5 #include<iostream>
     6 #include"windows.h"
     7 #define KEY_DOWN(vk_code)              (GetAsyncKeyState(vk_code)&0x8000?1:0)
     8 
     9 using namespace std;
    10 int _tmain(int argc, _TCHAR* argv[])
    11 {
    12     int nKeyState = 0;
    13     while (true)
    14     {
    15         system("CLS");
    16 
    17         if (KEY_DOWN(VK_DOWN))
    18         {
    19             nKeyState = abs(++nKeyState % 3);
    20         }
    21         if (KEY_DOWN(VK_UP))
    22         {
    23             --nKeyState;
    24             if (nKeyState < 0)
    25             {
    26                 nKeyState = 2;
    27             }
    28                 
    29         }
    30 
    31         cout << "■■■■■■■■■■■■" << endl;
    32         cout << "■■■■■■■■■■■■" << endl;
    33         if (nKeyState == 0)
    34         {
    35             cout << "■■  >-开始游戏    ■■" << endl;
    36             cout << "■■    游戏设置    ■■" << endl;
    37             cout << "■■    结束游戏    ■■" << endl;
    38 
    39         }
    40         else if (nKeyState == 1)
    41         {
    42             cout << "■■    开始游戏    ■■" << endl;
    43             cout << "■■  >-游戏设置    ■■" << endl;
    44             cout << "■■    结束游戏    ■■" << endl;
    45         }
    46         else if (nKeyState == 2)
    47         {
    48             cout << "■■    开始游戏    ■■" << endl;
    49             cout << "■■    游戏设置    ■■" << endl;
    50             cout << "■■  >-结束游戏    ■■" << endl;
    51         }
    52         cout << "■■■■■■■■■■■■" << endl;
    53         cout << "■■■■■■■■■■■■" << endl;
    54 
    55     }
    56     return 0;
    57 }
    游戏菜单

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

     1 // 作业2.cpp : 定义控制台应用程序的入口点。
     2 //
     3 
     4 #include "stdafx.h"
     5 #include<iostream>
     6 #include"Windows.h"
     7 
     8 using namespace std;
     9 int _tmain(int argc, _TCHAR* argv[])
    10 {
    11 
    12     
    13     int a = 0;
    14     int b = 0;
    15     int c = 0;
    16     int sum = 0;
    17 
    18     int i = 0;
    19     cout << "请输入一个整数" << endl;
    20     cin >> i;
    21     for (a; a<=i; a++)
    22     {
    23         for (b; b<=a; b++)
    24         {
    25             c += b;
    26         }
    27         sum += c;
    28     }
    29     cout << sum << endl;
    30     system("pause");
    31     
    32     return 0;
    33 }
    累加

    作业三——数字逆序

     1 // 作业3.cpp : 定义控制台应用程序的入口点。
     2 //
     3 
     4 #include "stdafx.h"
     5 #include<iostream>
     6 #include"Windows.h"
     7 
     8 
     9 using namespace std;
    10 
    11 int _tmain(int argc, _TCHAR* argv[])
    12 {
    13 
    14         int i;
    15         int len;
    16         char str[100];
    17 
    18         cout << "请输入要操作的数字" << endl;
    19         cin >> str;
    20         len = strlen(str);
    21         for (i = len - 1; i >= 0; i--)
    22         {
    23             cout << str[i];
    24         }
    25         cout << endl;
    26 
    27         system("pause");
    28         
    29         return 0;
    30 
    31     
    32 
    33 }
    数字逆序
  • 相关阅读:
    Java如何编写自动售票机程序
    install windows service
    redis SERVER INSTALL WINDOWS SERVICE
    上传文件
    This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed.
    解决Uploadify上传控件加载导致的GET 404 Not Found问题
    OracleServiceORCL服务不见了怎么办
    Access to the temp directory is denied. Identity 'NT AUTHORITYNETWORK SERVICE' under which XmlSerializer is running does not have sufficient permiss
    MSSQL Server 2008 数据库安装失败
    数据库数据导出成XML文件
  • 原文地址:https://www.cnblogs.com/kpxy/p/9356590.html
Copyright © 2011-2022 走看看