CPP课件C++程序设计比赛题解

上传人:E**** 文档编号:91228845 上传时间:2019-06-26 格式:PPT 页数:12 大小:31.50KB
返回 下载 相关 举报
CPP课件C++程序设计比赛题解_第1页
第1页 / 共12页
CPP课件C++程序设计比赛题解_第2页
第2页 / 共12页
CPP课件C++程序设计比赛题解_第3页
第3页 / 共12页
CPP课件C++程序设计比赛题解_第4页
第4页 / 共12页
CPP课件C++程序设计比赛题解_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《CPP课件C++程序设计比赛题解》由会员分享,可在线阅读,更多相关《CPP课件C++程序设计比赛题解(12页珍藏版)》请在金锄头文库上搜索。

1、C+程序设计比赛题解,第一题,1. 从键盘输入若干个同学的姓名(使用拼音表示),按字典顺序排序后输出。要求利用C+标准模板库STL或者你熟悉的其他类库编程实现。,#include #include #include #include using namespace std; int main() list lst; string c; int i; for(i=0;ic; lst.push_back(c); cout :iterator p=lst.begin( );,while(p!=lst.end() cout*pendl; p+; coutendl; lst.sort(); cout“排

2、序后“; p=lst.begin(); while(p!=lst.end() cout*pendl; p+; return 0; ,第二题,2. 设计一个简单的电话本软件。当用户从键盘输入联系人的姓名,能够查找到对应的电话号码。要求利用C+标准模板库或者你熟悉的其他类库编程实现。,#include #include #include using namespace std; int main() map m; int i,n; string s; char name20,phone20; coutn; getchar(); for (i=0;i (name,phone); ,cout :ite

3、rator p; p = m.find(s); if( p != m.end() cout second endl; else cout s “s phone number is not in the phonebook.n“; return 0; ,第三题,3. 完成下列的MyString类的定义和实现,并在主函数main( )中测试它。 class MyString public: MyString(const char *str = NULL); MyString(const MyString ,class MyString public: MyString(const char *str = NULL); MyString(const MyString ,MyString:MyString(const char *str) int length=strlen(str); m_data=new charlength+1; strcpy(m_data,str); MyString:MyString(const MyString ,MyString ,ostream ,

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 高等教育 > 大学课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号