- 博客(9)
- 收藏
- 关注
原创 动态数组(C++)
动态数组:1).从标准输入读入数据建立一个int型vector对象,然后动态创建一个与该vector对象大小一致的数组,把vector对象的所有元素复制给数组#include "stdafx.h"#include #include #include using namespace std;int main(){ cout vector ivec; int ival; while(cin>>iv
2009-08-07 10:46:00 329
原创 指针初步学习(C++)
pointer:1).指向const对象的指针:C++强制要求指向const对象的指针也必须具有const特性;定义时不需要对其进行初始化。允许对其重新赋值,使其指向另一个const对象,但不能通过它修改所指对象的值2).把一个const对象地址赋给一个普通的,非const对象的地址会导致编译错误,不能通过3).必须使用const *void类型的指针保存const对象的地址Example:#in
2009-08-06 11:21:00 224 1
原创 数组(C++)
数组:1).定义时:不能用变量定义数组的维数 不能用函数调用,不是常量表达式不能用来定义数组维数2).不允许数组直接复制和赋值:(error:ia1=ia2);3).数组的复制和输出#include "stdafx.h"#include using namespace std;int main(){ const size_t array_size=10; int ia
2009-08-05 16:43:00 190
原创 bitset(C++)
bitset:1).bitset对象初始化及换行输出#include "stdafx.h"#include #include #include #include using namespace std;int main(){ bitset bitvec; //32 bits,all zero int cnt=0; for(int ix=0;ix!=bitvec.size();++ix)
2009-08-05 10:50:00 626
原创 iterator(C++)
iterator(初步学习):1).const_iterator可以得到一个迭代器,自身的值可以改变,但不能用它来改变其所指向的元素的值.可用于const vector或非const vector。由于不能改写元素,const迭代器基本上没什么用处2).声明一个const迭代器时,必须初始化迭代器。一旦初始化,则不能被改变.#include "stdafx.h"#include #include
2009-08-04 10:56:00 2151 2
原创 入门C++体会(unexpected end of file while looking for precompiled header directive?)
unexpected end of file while looking for precompiled header directive解决方法:Project--Settings--C/C++--Precompiled Headers--Not using precompiled headers;1).求用户提供的两个数之间的数的和(若v1=v2,该程序又怎能说正确呢?)#include
2009-08-03 17:41:00 1978
原创 vector标准库类型(C++)
vector:仅能对确知已存在的元素进行下标操作,但下标操作也不能添加元素,必须用push_back()才可1).vector的输入和输出:(size_type类型)#include "stdafx.h"#include #include #include using namespace std;int main(){ //read words from the standard input
2009-08-03 17:35:00 313
原创 string标准库类型(C++)
C++中string的学习体会:string:1).不允许把两个字符串字面值连接起来,一个string对象+字符串字面值返回的是string对象.string::size_type只是string里方便移植性的定义的一种类型2).cout3).读入两个string对象,测试他们的大小,若不相等,指出两者中较大者#include "stdafx.h"#include #include using
2009-08-03 11:08:00 243
原创 java中 产生不重复地随机数程序
public class Test{ public static void main(String[] args) { int[] arr = new int[10]; for (int i = 0; i { arr[i] = (int) (Math.random() * 40) + 1;
2008-04-05 22:20:00 357
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人