当前位置: 首页 > news >正文

做跨境的网站有哪些杭州营销网站建设平台

做跨境的网站有哪些,杭州营销网站建设平台,水区建设局网站,ppt插件 网站《C游戏编程入门》第3章 for循环、字符串与数组: World Jumble 3.1 使用for循环03.counter.cpp 3.2 了解对象3.3 使用string对象03.string_tester.cpp 3.4 使用数组03.heros_inventory.cpp 3.6 多维数组03.tic-tac-toe_board.cpp 3.7 World Jumble程序03.word_jumble.cpp 3.1 使… 《C游戏编程入门》第3章 for循环、字符串与数组: World Jumble 3.1 使用for循环03.counter.cpp 3.2 了解对象3.3 使用string对象03.string_tester.cpp 3.4 使用数组03.heros_inventory.cpp 3.6 多维数组03.tic-tac-toe_board.cpp 3.7 World Jumble程序03.word_jumble.cpp 3.1 使用for循环 03.counter.cpp #include iostream using namespace std;int main() {cout Counting forward:\n;for (int i 0; i 10; i){cout i ;}cout \n\nCounting backward:\n;for (int i 9; i 0; --i){cout i ;}cout \n\nCounting by fives:\n;for (int i 0; i 50; i 5){cout i ;}cout \n\nCounting with null statements:\n;int count 0;for (; count 10;){cout count ;count;}cout \n\nCounting with nested for loops:\n;const int ROWS 5;const int COLUMNS 3;for (int i 0; i ROWS; i){for (int j 0; j COLUMNS; j){cout i , j ;}cout endl;}return 0; }3.2 了解对象 类与对象数据与函数封装。 3.3 使用string对象 03.string_tester.cpp #include iostream #include string using namespace std;int main() {// 创建string对象string word1 Game;string word2(Over);string word3(3, !);string phrase word1 word2 word3; // string对象连接cout The phrase is: phrase \n\n;cout The phrase has phrase.size() characters in it.\n\n; // size()成员函数cout The character at position 0 is: phrase[0] \n\n; // 索引获取字符cout Changing the character at position 0.\n;phrase[0] L; // 索引字符赋值cout The phrase is now: phrase \n\n;for (unsigned int i 0; i phrase.size(); i) // 循环访问单个字符{cout Character at position i is: phrase[i] endl;}cout \nThe sequence Over begins at location ;cout phrase.find(Over) endl; // find()查找字符串if (phrase.find(eggplant) string::npos) // 未找到{cout eggplant is not in the phrase.\n\n;}phrase.erase(4, 5); // 移除从位置4开始的长度为5个字符的子字符串cout The phrase is now: phrase endl;phrase.erase(4);cout The phrase is now: phrase endl;phrase.erase();cout The phrase is now: phrase endl;if (phrase.empty())//是否空{cout \nThe phrase is no more.\n;}return 0; }3.4 使用数组 存储多个相同类型的元素。 03.heros_inventory.cpp #include iostream #include string using namespace std;int main() {const int MAX_ITEMS 10;string inventory[MAX_ITEMS];//创建数组int numItems 0;//数组索引inventory[numItems] sword;inventory[numItems] armor;inventory[numItems] shield;cout Your items:\n;for (int i 0; i numItems; i){cout inventory[i] endl;}cout \nYou trade your sword for a battle axe.;inventory[0] battle axe;cout \nYour items:\n;for (int i 0; i numItems; i){cout inventory[i] endl;}cout \nThe item name inventory[0] has ;cout inventory[0].size() letters in it.\n;cout \nYou find a healing potion.;if (numItems MAX_ITEMS){inventory[numItems] healing potion;}else{cout You have too many items and cant carry another.;}cout \nYour items:\n;for (int i 0; i numItems; i){cout inventory[i] endl;}return 0; }3.6 多维数组 03.tic-tac-toe_board.cpp #include iostream using namespace std;int main() {const int ROWS 3;const int COLUMNS 3; // 创建多维数组char board[ROWS][COLUMNS] {{O, X, O},{ , X, X},{X, O, O}};cout Heres the tic-tac-toe board:\n;for (int i 0; i ROWS; i){for (int j 0; j COLUMNS; j){cout board[i][j]; // 多维数组索引}cout endl;}cout \nX moves to the empty location.\n\n;board[1][0] X;cout Now the tic-tac-toe board is:\n;for (int i 0; i ROWS; i){for (int j 0; j COLUMNS; j){cout board[i][j];}cout endl;}cout \nX wins!;return 0; }3.7 World Jumble程序 03.word_jumble.cpp #include iostream #include string #include cstdlib #include ctime using namespace std;int main() {enum fields{WORD,HINT,NUM_FIELDS};const int NUM_WORDS 5; // 单词列表以及提示const string WORDS[NUM_WORDS][NUM_FIELDS] {{wall, Do you feel youre banging your head against something?},{glasses, These might help you see the answer.},{labored, Going slowly, is it?},{persistent, Keep at it.},{jumble, Its what the game is all about.}};// 随机选择单词srand(static_castunsigned int(time(0)));int choice (rand() % NUM_WORDS);string theWord WORDS[choice][WORD]; // word to guessstring theHint WORDS[choice][HINT]; // hint for word// 单词乱序string jumble theWord; // jumbled version of wordint length jumble.size();for (int i 0; i length; i){int index1 (rand() % length);int index2 (rand() % length);char temp jumble[index1];jumble[index1] jumble[index2];jumble[index2] temp;}// 欢迎界面cout \t\t\tWelcome to Word Jumble!\n\n;cout Unscramble the letters to make a word.\n;cout Enter hint for a hint.\n;cout Enter quit to quit the game.\n\n;cout The jumble is: jumble;string guess;cout \n\nYour guess: ;cin guess;// 游戏主循环while ((guess ! theWord) (guess ! quit)){if (guess hint){cout theHint;}else{cout Sorry, thats not it.;}cout \n\nYour guess: ;cin guess;}// 游戏结束if (guess theWord){cout \nThats it! You guessed it!\n;}cout \nThanks for playing.\n;return 0; }
http://www.pierceye.com/news/751620/

相关文章:

  • 网站在线交谈wordpress信息填写
  • 服饰网站建设微网站建设 合同
  • dede网站 远程生成wordpress后台不能登陆
  • word如何做网站链接湖南省绿色建筑信息平台
  • v9网站模板网站建设六道
  • php网站开发原理企业门户网站费用
  • 白银市建设管理处网站定制网站建设和运营
  • 免费音乐网站建设新闻资讯建站服务商
  • 佛山市建设企业网站服务机构普通网站建设计入什么科目
  • 阿里虚拟机建设网站网络科技有限公司营业执照
  • 如何申请建设网站首页培训机构怎么做线上推广
  • 网站维护升级访问中做网站工单
  • 如何用ae做模板下载网站电脑网站建设规划
  • 北京京水建设集团有限公司网站西青做网站
  • 自己建的网站可以用笔记本做服务器吗网站建设后台系统有哪些
  • 做的asp网站手机号码网站开发软件手机版
  • android 做电子书下载网站网络热词作文
  • 网络网站销售龙岩建筑网
  • 专门找事做的网站iis7 wordpress伪静态规则
  • 做字体的网站济宁网站建设 济宁智雅
  • 工程门户网站建设怎样制作表白网站
  • 手机如何创建个人网站上海 .net网站建设
  • 小程序app软件定制开发首页排名优化公司
  • 红酒 专业 网站建设视频网站后台
  • 宁波网站建设58同城百度突然搜不到网站
  • 网站开发技术和seo的联系wordpress发邮件卡主
  • 网站开发安全模块方案网站运营方案怎么写?
  • 章丘网站制作手机网站 微信平台
  • 自定义功能的网站做坏事网站
  • 做农村电子商务的网站有哪些wordpress批量修改引用网址