自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(27)
  • 收藏
  • 关注

原创 布局new操作符的用法

<br /> #include <iostream>using namespace std;class Text{private: int i; char * s;public: Text(int a = 8, char * b= "nothing") { i = a; s = new char[a]; strncpy(s, b, a-1); s[a-1] = '/0'; } ~Text() { delete [] s

2011-01-13 21:02:00 491

原创 仿string类

#ifndef _STRING1_H_#define _STRING1_H_#include using std::istream;using std::ostream;class Strng{private: int len; char * str; enum { CINMAX = 100}; static int NUMSTR;public: Strng(); Strng(const char *); Strng(const Strng

2011-01-13 19:45:00 384

原创 strlen

<br />好像include<iostream>就可以了, 但是据说是在string.h里,<br />具体用法:返回字符串的长度, 不包括末尾的‘/0’<br />程序示例如下:<br />#include <iostream>using namespace std;int main(){ char ch[8] = "kelso"; ch[5] = '/0'; cout << ch << endl; //输出kelso int a; a = strlen(ch);

2011-01-13 00:39:00 334

原创 类继承一个简单的例子

brass.h#ifndef _BRASS_H_#define _BRASS_H_class Brass{private: enum {MAX = 35}; char fullName[MAX]; // 客户姓名 long accNum; //账号 double balance; //当前结余public: Brass (const char * s = "Nullbody", long an = -1, double bal =

2010-12-30 23:28:00 633

原创 赌博游戏

<br />#include <iostream>#include <cstdlib>#include <ctime>using namespace std;enum ZhuangTai {WIN, LOSE, CON, UNKNOW};struct Manager { int num; int ya; ZhuangTai zt; Manager() { num = 0; ya = 0; zt = UNKNOW;

2010-11-15 15:16:00 521

原创 学生成绩, 学号, 姓名。小程序

<br />#include <iostream>#include <list>#include <vector>#include <string>using namespace std;struct Student{ string name; unsigned number;};struct Score{ float mark; unsigned number;};struct Manager{

2010-11-06 11:53:00 1808

原创 stock.h

#ifndef STOCK_H_#define STOCK_H_class Stock{private: char company[30]; //公司名 int shares; //股票数 double share_val; //股票单价 double t

2010-02-27 20:51:00 486

原创 7-12

//座标的两种表标方法的转换#include#includestruct polar{ double distance; double angle;};struct rect{ double x; double y;};polar rectToPolar(rect xypos);void showPolar(polar dapos);in

2010-02-03 00:14:00 492

原创 7-10

//返回C风格字符串的函数#includechar* buildstr(char c, int n);int main(){ using namespace std; int time; char ch; cout << "Enter a character: "; cin >> ch; cout << "Enter an integer: "; cin

2010-02-03 00:12:00 375

原创 7-11

//travel, 结构#includestruct travel_time{ int hours; int mins;};const int Mins_per_hr = 60;travel_time sum(travel_time t1, travel_time t2);void show_time(travel_time t);int main(){

2010-02-03 00:12:00 395

原创 79

#includeint c_in_str(const char * str, char ch);int main(){ using namespace std; char mmm[15] = "minimum"; char * wail = "ululate"; int ms = c_in_str(mmm, m); int us = c_in_str(wail,

2010-02-03 00:11:00 646

原创 传递区间数组

//不是用size,而是用一个数组区间来传递数组#includeusing namespace std;const int Arsize = 8;int sum_array(const int * begin, const int * end);int main(){ using namespace std; int ar[Arsize]={1,2,4,8,16,3

2010-02-01 22:19:00 334

原创 复制文本

#include#include#includeusing namespace std;int main(){ char ch[100]; string str; ofstream outFile; ifstream inFile; cout<<"Enter the file your want copy to:"<<endl; cin.getline(

2010-01-31 18:50:00 288

原创 //outfile.cpp--writing to a file

  //outfile.cpp--writing to a file#include#include //for file I/Oint main(){ using namespace std; char automobile[50]; int year; double a_price; double d_price; ofstream outF

2010-01-29 22:25:00 445

原创 飞机订票

//飞机分配座位#includeusing namespace std;void mainyuan(int [],int* ,char);//满员后处理void syt(int [],int);//用图形打印座位的位置const int size=20;int main(){ int seat[size]={0}; int td=0,pt=size/2;/

2009-12-03 00:06:00 673

原创 对一个大型数组进行二元搜索

 //对一个大型数组进行二元搜索#includeusing namespace std;int search(const int ar[], int key,int low,int high);//声明void sort(int [],int );int main(){ const int arsize=1000; int ar[arsize]; i

2009-11-18 22:29:00 415

原创 对一个大型数组进行排序,求平均,中间数等操作,第一次写这么长代码,累~

 //对一个大型数组进行排序#include#includeusing namespace std;void mean(const int[],int);//数组及平均数void median(int[],int);//中间数void made(int[],int[],int);//出现最多次数的那个数void bubbleSort(int[],int);//排序

2009-11-14 21:54:00 1052

原创 将数组里的成员升序排列

 //将数组里的成员升序排列#includeusing namespace std;const int arsize=10;int main(){ int hold;//用转数 int a[10]={23,2,654,7,36,4,86,53,856,654};//一个十个成员的数组 for(int i=0;i<arsize-1;i++)//九次循环 {

2009-11-13 22:36:00 413

原创 传递数组给函数

 //传递数组给函数是引用调用,可以改变其值//传递数组中的成员是按值传递,传递的只是其副本#includeusing namespace std;void changeArray(int[],int);//改变数组。要加[]void changeInt(int);//改变数组中的成员值int main(){ int a[5]={1,2,3,4,5,};//声明一个

2009-11-13 22:18:00 360

原创 猜数游戏

//猜数游戏#include#includeusing namespace std;int main(){ srand(time(0)); int sj=0;//用来记录随机数 int caishu=0;//用来记录用户猜的数 int counter=0;//用来记录用户猜的次数 sj=1+rand()%1000;//用来记录这个随机数 cout<<"我

2009-11-12 22:48:00 355

原创 筛子游戏

 //筛子游戏#include#includeusing namespace std;int main(){ enum gamestars{con,win,loss}; srand(time(0));//随机数 int dianshu=0; int dianshu2=0;//记录筛子点数 int count=0;//上一次筛子点数 gamestars

2009-11-12 22:22:00 1287

原创

 最近心情很烦,都没什么兴趣去学习了,每次想到这一点我就觉得很浪费时间,逼自己去做!!I dont care of you,so whatever you say! Ill give you a smile.hehe~~不过与生俱来的自负不知道怎么甩掉~~  做人是要谦虚一点,管理好自己的情绪。control ! than all of you! hehe~~

2009-11-11 22:12:00 304

原创 用*号输出数组对应的个数

//用*号输出数组对应的个数#include#includeconst int as=10;int main3(){ using namespace std; int ar[as]={1,2,3,4,5,6,7,8,9,10}; for(int i=0;i<as;i++) { cout<<setw(10)<<ar[i]<<setw(10); f

2009-11-11 21:02:00 360

原创 用new来为指针分配内存

//用new来分配内存#includeusing namespace std;int main(){ int * pt=new int;//使用new来为指针pt分配一个未命名的内存空间 *pt=1001;  //new int 告诉程序,需要适合存储适合int类型数据的内存。new操作符根据数据类型来确定需要多少字节内存来存储。  cout double * pd=new dou

2009-10-26 21:42:00 3385

原创 枚举

//C++的enum工具提供了另一种创建符号常量的方式,这种方式可以代替const #include using namespace std; enum theDay{ yesterday,//默认第一个值为0,也就是说yesterday的值为0,后面的today递加,为1; today,//如果yesterday被显示指定为yesterday=1;那么此时

2009-10-25 20:32:00 249

原创 共用体

//------------------------共用体--union--------------------//共用体是一种数据格式,它能够存储不同类型的数据类型,但是每次能存一种。//其句法和结构相似#include using namespace std; union one4all{ int int_val; long long_val;

2009-10-25 20:31:00 252

原创 C++学习笔记之结构

//结构是用户定义的类型,而结构声明定义了这种类型的数据属性, //定义了类型以后,便可以创建这种类型的变量,//因些创建结构包括两步, 首先,定义结构描述————它描述并标记了能够存储在结构中的各种数居类型//然后按描述创建结构变量(结构数据对像) #include  struct inflatable//声明一个结构,名为inflatable;{ c

2009-10-25 20:29:00 371

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除