开始学习C++
2011-05-14 14:11
351 查看
虽然,都已经学了好几天了,但现在说出来下,还不算晚哈.
最近的代码会略少,算法的东西前进得不多.
刚刚写了这个东西.毕竟还没有学完,就是按照当前章节的要求写出来的.
加油吧!我终于开始学习C++了!
贴咯.贴完出去打会球!
最近的代码会略少,算法的东西前进得不多.
刚刚写了这个东西.毕竟还没有学完,就是按照当前章节的要求写出来的.
加油吧!我终于开始学习C++了!
贴咯.贴完出去打会球!
// 6-6-2011-05-14-13.08.cpp -- 第六章第六题 #include "stdafx.h" #include <iostream> const char NUL = '/0' ; const int NAMESIZE = 20 ; struct Patron { char name[NAMESIZE] ; double money ; } ; int _tmain(int argc, _TCHAR* argv[]) { using namespace std ; Patron * pTP ; int num, i ; cout << "Input the number of patrons:" ; if (!(cin >> num) || num <= 0) { cout << "Wrong input./n" ; return 0 ; } cin.get () ; pTP = new Patron[num] ; for (i = 0; i < num; ++i) { cout << "Please input information of current patron, [" << i + 1 << "/" << num << "]/n" ; cout << "Now input name:" ; cin.getline (pTP[i].name, NAMESIZE) ; cin.clear () ; cout << "And money:" ; cin >> pTP[i].money ; cin.get () ; } // Output cout << "Grand Patrons:/n" ; for (i = 0; i < num; ++i) { if (pTP[i].money > 10000.0) { if (NUL == pTP[i].name[0]) cout << "Name : none/n" ; else cout << "Name : " << pTP[i].name << endl ; } } cout << "Patrons:/n" ; for (i = 0; i < num; ++i) { if (pTP[i].money <= 10000.0) { if (NUL == pTP[i].name[0]) cout << "Name : none/n" ; else cout << "Name : " << pTP[i].name << endl ; } } delete []pTP ; return 0 ; }
相关文章推荐
- 【C++】笨鸟起飞——开始我的C++学习之路
- 开始学习C++
- 第二章《开始学习C++》
- 开始学习C++
- c++学习总结系列--开始(复习)
- 开发者应该开始学习 C++ 了
- 《c++ primer plus》读书笔记:2.开始学习c++
- 开始学习C++
- c++ peimer plus第二章 开始学习c++
- C++Primer Plus笔记——第二章 开始学习C++及课后习题答案
- 第2章 开始学习C++ 程序清单、编程练习
- 开始全力学习c++
- 第二章开始学习C++
- C++ Primer Plus 学习笔记之第二章开始学习C++
- 2010.06.10 开始c,C++学习之旅
- 第二章 开始学习C++
- 【读书笔记:C++ primer plus 第六版 中文版】第2章:开始学习C++
- 开始学习C++了
- 开始学习thinking C++
- C++学习第一天小结(东西比较杂 因为还没开始正式系统学习 只是通过例子了解到的各个杂知识点)