| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 644 人关注过本帖
标题:上学第一个星期的测验题 : 错在哪里
只看楼主 加入收藏
kaneqeqeq
Rank: 1
等 级:新手上路
帖 子:59
专家分:0
注 册:2007-7-3
收藏
 问题点数:0 回复次数:3 
上学第一个星期的测验题 : 错在哪里
#include <iostream>

// Prototypes
void DisplayMenu();
int GetSelection();

////////////////////////////////////////
// The main() function.
////////////////////////////////////////
int main()
{
// Display the menu.
DisplayMenu();

// Get the menu selection.
int selection;
selection = GetSelection();

// Select the matching process
switch (selection)
{
case 1:
std::cout << "Processing Receivables" << std::endl;
break;
case 2:
std::cout << "Processing Payables" << std::endl;
break;
case 3:
std::cout << "Quitting" << std::endl;
break;
default:
std::cout << "\aInvalid selection" << std::endl;
break;
}

return 0;
}

////////////////////////////////////////
// Display a menu.
////////////////////////////////////////
void DisplayMenu()
{
std::cout << "--- Menu ---" << endl;
std::cout << "1=Receivables" << endl;
std::cout << "2=Payables" << endl;
std::cout << "3=Quit" << endl;
}

////////////////////////////////////////
// Read a menu selection from the
// keyboard.
////////////////////////////////////////
int GetSelection()
{
int selection;
std::cout << "Enter Selection: ";
std::cin >> selection;

return selection;
}
搜索更多相关主题的帖子: selection int main menu The 
2007-07-14 19:41
一番宝瓶
Rank: 1
等 级:新手上路
帖 子:239
专家分:0
注 册:2007-7-14
收藏
得分:0 

既然你不想用using namespace std; 把整个标准命名空间展开的话,DisplayMenu() 函数里的endl 应该为std::endl


2.3.2.2.2.0
2007-07-14 20:02
kaneqeqeq
Rank: 1
等 级:新手上路
帖 子:59
专家分:0
注 册:2007-7-3
收藏
得分:0 
我終於知道 using namespace std 用法了,你教得好好 !!

還有,你的圖片很有 style !! XD

[此贴子已经被作者于2007-7-14 20:07:22编辑过]

2007-07-14 20:06
kaikai19958
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-7-13
收藏
得分:0 
厉害!我也学到了点东西.谢谢!
2007-07-14 23:47
快速回复:上学第一个星期的测验题 : 错在哪里
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017168 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved