mydjm

 

05 2012 档案

链表插入操作~
摘要:1 #include <iostream> 2 using namespace std; 3 4 5 typedef struct node 6 { 7 int data; 8 struct node* next; 9 }Node;//节点结构体10 11 12 Node* create(int n)//初始化头指针为空~13 {14 Node* head=(Node*)(malloc(sizeof(Node)));15 head->next=NULL;16 head->data=n;17 return head;18 }19 20 voi... 阅读全文

posted @ 2012-05-10 10:33 mydjm 阅读(427) 评论(0) 推荐(0)

字符串转换为整数(大数会用到滴)
摘要:1 #include <iostream> 2 using namespace std; 3 4 void main() 5 { 6 int num=0,i=0; 7 char c[20],temp[20]; 8 cout<<"请输入字符串:"<<endl; 9 cin>>c;10 strcpy(temp,c);11 while (temp[i]!='\0')12 {13 num=num*10+temp[i]-'0';14 i++;15 }16 cout<<"整数为:&qu 阅读全文

posted @ 2012-05-10 10:26 mydjm 阅读(394) 评论(0) 推荐(0)

整数转换成字符串(大数会用到滴)
摘要:1 #include <iostream> 2 #include <complex> 3 using namespace std; 4 5 void main() 6 { 7 int temp,num,i=0; 8 char c[20]; 9 cout<<"请输入整数"<<endl;10 cin>>num;11 temp=num;12 13 while(temp!=0)14 {15 c[i]=temp%10+'0';16 i++;17 temp/=10;18 }19 ... 阅读全文

posted @ 2012-05-10 10:15 mydjm 阅读(346) 评论(0) 推荐(0)

多态~
摘要:1 #include <iostream> 2 using namespace std; 3 4 class Person 5 { 6 public: 7 int age; 8 int name; 9 virtual void pee()10 {11 cout<<"man stand and woman sit"<<endl;12 }13 };14 15 class man : public Person16 {17 void pee()18 {19 cout<<"man stand~"<<en 阅读全文

posted @ 2012-05-06 14:48 mydjm 阅读(176) 评论(0) 推荐(0)

构造函数的参数给值~
摘要:1 #include <iostream> 2 using namespace std; 3 4 class A 5 { 6 protected: 7 int m_data; 8 public: 9 A(int data=1)//给了个值~10 {11 m_data=data;12 }13 int GetData()14 {15 return m_data;16 }17 };18 19 void main()20 {21 A a(2);22 A b;//无参,别加括号,那会变成函数~23... 阅读全文

posted @ 2012-05-06 14:46 mydjm 阅读(175) 评论(0) 推荐(0)

导航