上一页 1 ··· 3 4 5 6 7
摘要: 输入:1 2 3 4 5输出:1 2 3 4 5 5输入:1 2 3 4 5 6 7输出:1 2 3 4 5 6 7 7 需要输入EOF表示输入结束,如下: windows下, 请按 ctrl+z; Unix/Linux下, 请按 Ctrl+D. 关于cin的返回值可以参考:http://blog. 阅读全文
posted @ 2016-03-25 23:43 hu983 阅读(1547) 评论(0) 推荐(0) 编辑
摘要: 一、运行如下程序段 分析:程序崩溃。在函数中给指针分配空间,实际上是给指针的临时变量分配空间,函数结束后临时变量消亡,str仍然为NULL。改变指针需要传入二级指针。函数名需改为 阅读全文
posted @ 2016-03-25 18:26 hu983 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 4 using namespace std; 5 6 int main() 7 { 8 string line; 9 getline(cin,line,'-'); //getline用法 10 cout中包含 12 cout<<line[0]<<endl; //访问数组中的字符 13 ... 阅读全文
posted @ 2016-03-23 21:08 hu983 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 输出:10,20,50 参考资料: 《征服C指针》(http://avnpc.com/pages/c-pointer) 阅读全文
posted @ 2016-03-23 11:19 hu983 阅读(531) 评论(0) 推荐(0) 编辑
摘要: 例如输入的数组为1, -2, 3, 10, -4, 7, 2, -5,和最大的子数组为3, 10, -4, 7, 2,因此输出为该子数组的和18。 阅读全文
posted @ 2016-03-22 22:11 hu983 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 如果cin出现了问题,那么cin调用fail()就会返回真,进入循环后处理错误信息 阅读全文
posted @ 2016-03-21 16:31 hu983 阅读(1417) 评论(0) 推荐(0) 编辑
摘要: 输出为1 阅读全文
posted @ 2016-03-21 16:20 hu983 阅读(165) 评论(0) 推荐(0) 编辑
摘要: Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a numbe 阅读全文
posted @ 2016-03-21 14:39 hu983 阅读(238) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7