有问题的编程
文章平均质量分 70
chosen13
这个作者很懒,什么都没留下…
展开
-
定义附加项
#include #include using namespace std;int main (){ string k1,k2; cout << "Enter some words:(Ctrl + I to end)" << endl; while(cin >> k1) {#ifndef NDEBUG cout << endl << "调试:" << k1 <<翻译 2016-02-20 20:29:15 · 276 阅读 · 0 评论 -
传递指向指针的引用
#include using namespace std;void ptrswap (int *&v1,int *&v2) // 指向指针的引用,{ int *tmp = v2; v2 = v1; v1 = tmp;}int main (){int i = 10;int j = 20;int *pi = &i; // 变换前:*pi指向i,int *p原创 2016-02-20 21:25:37 · 169 阅读 · 0 评论 -
函数参数传递2
#include using namespace std;void printValues(int *x, size_t size) //x指向数组的第一个元素,{ for (size_t i = 0; i != size; ++i) cout << x[i] << endl;}void printValues_2(int x[], size_t size) // int x[翻译 2016-02-21 13:17:57 · 177 阅读 · 0 评论 -
条件状态
#include using namespace std;void check_cin_state(istring &is){ cout << "检查cin的状态:" << endl; if (cin is.bad()) cout << "cin bad()" << endl; else cout << "cin not bad()" << endl; if (cin i翻译 2016-02-22 20:18:59 · 271 阅读 · 0 评论 -
文件流对象的使用
#include #include #include using namespace std;int main(){ string s; //ifstream ifs("file1.txt", ifstream::in);//这是文件模式, ifstream ifs("file1.txt"); // 这是默认的文件模式, ifs >> s; ifs.close()翻译 2016-02-23 14:09:39 · 527 阅读 · 0 评论