代码和解释:
#include "stdafx.h"
#include
#include
#include
using namespace std;
class test{
int *p;
public:
test(int value){
p = new int(value);
cout>"<<endl;
cout<<"p的地址为"<<&p<<";p的值为"<<p <<" ...
分类:
编程语言 时间:
2014-09-03 22:46:37
阅读次数:
203
C语言中,数组名作为参数传递给函数时,退化为指针,sizeof对指针操作结果应该是4。例子如下:#includeusing namespace std;void Swap_arr(char* charArr){ int len = sizeof(charArr); cout usin...
分类:
编程语言 时间:
2014-09-03 21:01:47
阅读次数:
197
#include#include#includeusing namespace std;int main(){ ifstream file("1.txt"); char ch[20]; cout<<"getline: "<<endl; while(file.getline(c...
分类:
其他好文 时间:
2014-09-03 18:03:57
阅读次数:
250
#include#include#includeusing namespace std;int main(){ cout>noskipws; while(cin>>ch) cout>skipws;}
分类:
其他好文 时间:
2014-09-03 16:28:26
阅读次数:
166
场景:在Qt里,不能使用std::cout,所以使用下面的函数就可以打印cout的内容了
#include
#include
static void OpenConsole()
{
AllocConsole();
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
int hCrt = _op...
分类:
其他好文 时间:
2014-09-02 19:58:05
阅读次数:
298
1-2 输出N个数的平方和立方值
Time Limit: 1000MS Memory limit: 65536K
题目描述
通过本题目的练习可以掌握C++的输入、输出方法
利用VC++开发环境,创建一个控制台应用程序,利用cin、cout语句使得程序能够根据输入的整数值,输出相应的平方和立方值
输入
一个整数
输出
由两部分组成,第一部分占一...
分类:
其他好文 时间:
2014-09-02 17:47:55
阅读次数:
196
一 int转string第一种方法:#include #include using namespace std;int main(){ int n = 65535; char t[256]; string s; sprintf(t, "%d", n); s = t; cout #include...
分类:
其他好文 时间:
2014-09-02 17:30:44
阅读次数:
279
int ia[3][4] = {1,2,3,4,5,6,7,8};//下标for (int i = 0; i < 3; i++){ for (int j = 0; j < 4; j++) { cout << ia[i][j] << endl; }}//指针for (i...
分类:
编程语言 时间:
2014-09-02 12:17:14
阅读次数:
218
#include void change (int a){ a = 10;}void change (int *a){ *a = 10;}int main(int argc, const char * argv[]){ int a = 5; change(a); std::cout<<a<...
分类:
其他好文 时间:
2014-09-02 12:13:54
阅读次数:
162
#include using namespace std;int chy_max(int t1,int t2){ if(t1 left); cout value right); } } private: ...
分类:
其他好文 时间:
2014-09-01 15:32:23
阅读次数:
227