自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(3)
  • 资源 (6)
  • 收藏
  • 关注

原创 Android onPause

最近在做文件管理器,有一个需求,当应用失去焦点时,dismiss掉应用的dialog. 在想怎么做,因为貌似弹出对话框时用到onPause()回调。那么的话要在onStop里面处理。。。 但是实际上,正如一个师兄以前给我提过的那样,一个对话框是不会使应用进入到onPause的。只有是一个透明的activity在当前activity之前,才会使activity只到onPause状

2012-03-30 10:03:53 911

原创 Android保存状态(onSaveInstanceState)与恢复状态(onRestoreInstanceState)

Activity中可以实现两个方法来存储和恢复Activity状态: 1.onSaveInstanceState(Bundle b)     在此方法中保存一些临时数据到bundle中。UI的状态自动会保存。 2.onRestoreInstanceState(Bundle b) 此方法的调用时机是在onStart和onPostCreate方法之后。在bundle中存放着onSa

2012-03-28 18:24:19 1232

转载 一个理解wait()与notify()的例子

下面是我原来在CSDN论坛上看到的一个贴子,涉及到同步,wait(),notify()等概念的理解,我试着根据原来的一些回复和Think in Java上的相关概念将wait()和notify()这两个方法剖析了一下,欢迎指教.   问题如下:   //分析这段程序,并解释一下,着重讲讲synchronized、wait(),notify 谢谢!   class ThreadA

2012-03-28 18:08:59 313

Visual C++数据库编程技术与实例.rar

包含数据库编程的实例代码若干。是学习数据库编程的好资料

2010-05-15

C++谭浩强(课件源码正文图片)

C++ 谭浩强版的课件源码正文图片 包括各个章节的。

2010-05-15

c++ 控制台实现学生管理

(改进版)使用windows控制台实现的学生管理系统,具有一些实用的功能,主要用来联系和学习编程。 比以前的技术上好一点。

2009-06-05

简单的加密程序(采用简单的固定密钥)

设置密码+加密+保存密码 装载密码+解密。

2009-05-14

电话簿(c++编写的,初学者可以看一下)

/************************************************* Copyright (C), 2008- , mekinglong of cumtcs File name:面向对象8(面向对象8.cpp) Author: 计07-2 秦杰 Version: 1.00 Date: 08.11.12 Description:编写程序实现一个简单的电话记录簿,要求记录的个人信息包括: 姓名,单位,家庭电话,移动电话。具体功能如下: 1.创建信息链表并以磁盘文件保存。 2.读取磁盘文件并显示输出所有人的移动电话。 3.按姓名或单位查询家庭电话。 4.通过姓名和单位确定个人,修改其电话信息并存盘. Others: .... Function List: // 主要函数列表,每条记录应包括函数名及功能简要说明 1.main() 完成各种提示与主操作输入输出 History: <author> <time> <version > <desc> *****************************************************/ #include <iostream> #include <assert.h> #include <string> #include <cstring> #include <fstream> #include <iomanip> using namespace std; class telist; class Node { private: char name[30]; char workplace[50]; char hometel[50]; char mobiletel[50]; Node *next; public: friend class telist; friend void load(telist&); }; class telist { private: Node *head; Node *tail; public: telist() { head=tail=NULL; } telist(Node* h,Node *t):tail(t),head(h){} void add(); void del(); void show(); Node* search(); void change(); void store(); Node* find1(); Node* find2(); friend void load(telist&); }; void operate(string ,telist &); void load(telist &); int main() { system("cls"); cout<<"欢迎使用电话簿管理系统:\n"; telist tele; load(tele); string strord; do { cout<<"输入你的操作:\n"; cout<<"1.加入新的电话记录。\n"; cout<<"2.显示输出所有人的移动电话\n"; cout<<"3.按姓名或单位查询家庭电话\n"; cout<<"4.通过姓名和单位确定个人,修改其电话信息并存盘.\n"; cout<<"5.删除一个人信息并存盘。\n"; cout<<"0.退出程序。\n"; cin>>strord; operate(strord,tele); system("cls"); }while(strord!="0") ; system("pause"); system("cls"); return 0; } void operate(string str,telist &t) { if(str=="1") t.add(); else if(str=="2") t.show(); else if(str=="3") t.search(); else if(str=="4") t.change(); else if(str=="5") t.del(); else if(str=="0") t.store(); else cout<<"输入错误!\n"; system("pause"); } void load(telist &t) { ifstream infile("电话簿.dat",ios::in|ios::binary); if(infile == NULL) { cerr<<"打开电话簿失败!!\n"; t.head=t.tail=NULL; return; } if(!infile.eof()) { cout<<"没有数据\n"; t.head=t.tail=NULL; return ; } Node *temp=new Node; t.head=temp; Node *temp2; infile.read ((char*)temp,sizeof(Node)); while(!infile.eof()||temp->next==NULL) // { temp->next=new Node; temp2=temp; temp=temp->next; infile.read ((char*)temp,sizeof(*temp)); t.tail=temp; } temp->next=NULL; delete(temp); t.tail=temp2; t.tail->next=NULL; // delete temp; assert(t.tail->next==NULL); infile.close(); // delete infile; } void telist::add() { if(head==tail&&tail==NULL) { Node * newnode; newnode=head=tail=new Node; if(!newnode) { cout<<"警告:内存分配失败!\n"; return; }//if cout<<"姓名:\n"; cin>>newnode->name; cout<<"工作单位:\n"; cin>>newnode->workplace; cout<<"家庭电话:\n"; cin>>newnode->hometel; cout<<"移动电话:\n"; cin>>newnode->mobiletel; newnode->next=NULL; }//if else{ Node *temp; temp=new Node; tail->next = temp; if(!temp) { cout<<"警告:内存分配失败!\n"; return; } cout<<"姓名:\n"; cin>>temp->name; cout<<"工作单位:\n"; cin>>temp->workplace; cout<<"家庭电话:\n"; cin>>temp->hometel; cout<<"移动电话:\n"; cin>>temp->mobiletel; temp->next=NULL; tail=temp; }//else } void telist::del() { cout<<"先确定你要删除的人:\n"; Node *temp=search(); Node *p=head; if(temp==NULL) { cout<<"没找到要找的人!\n"; return ; } if(p==temp) { cout<<"确定删除?(y或n)"; char ord1; cin>>ord1; if(ord1=='N'||ord1=='n') return; if(ord1=='Y'||ord1=='y') { head=head->next; if(p==tail) tail=NULL;//wenti zaizheli } } else { for(;(p->next)!=temp;) { p=p->next; } cout<<"确定删除?(y或n)"; char ord; cin>>ord; if(ord=='N'||ord=='n')return; if(ord=='Y'||ord=='y')//if1 { if(temp==tail)//if2 { delete temp; tail=p; }//if2 else { p->next=temp->next; delete temp; }//else }//if1 }//else store(); }//del void telist::show() { Node *temp=head; for(;temp!=NULL;) { cout<<setw(15)<<temp->name<<setw(15)<<temp->workplace; cout<<setw(15)<<temp->hometel<<setw(15)<<temp->mobiletel<<endl; temp=temp->next; } return; } Node* telist::search() { // char sname[30]; // char sworkplace[50]; int ord; cout<<"按照什么查询?\n"; cout<<"1.名字。\n"; cout<<"2.工作单位。\n"; cin>>ord; for(;!cin;) { cout<<"error!"; cin>>ord; } switch(ord) { case 1:return(find1());break; case 2:return(find2());break; default:cout<<"警告:操作错误!\n";return 0; } } Node* telist::find1() { char sn[30]; cout<<"请输入姓名:\n"; cin>>sn; cout<<endl; Node *temp=head; for(;temp;temp=temp->next) { if(!strcmp(sn,temp->name)) { cout<<setw(15)<<temp->name<<setw(15)<<temp->workplace; cout<<setw(15)<<temp->hometel<<setw(15)<<temp->mobiletel<<endl; return temp; } if(temp->next==NULL) { cout<<"NO FIND!\n"; return NULL; } else return NULL; } } Node* telist::find2() { char sw[50]; cout<<"请输入工作单位:\n"; cin>>sw; cout<<endl; Node *temp=head; for(;temp;temp=temp->next) { if(!strcmp(sw,temp->workplace)) { cout<<setw(15)<<temp->name<<setw(15)<<temp->workplace; cout<<setw(15)<<temp->hometel<<setw(15)<<temp->mobiletel<<endl; return temp; break; } if(temp->next==NULL) { cout<<"NO FIND!\n"; return NULL; } else return NULL; } } void telist::store() { Node * temp=head; ofstream outfile("电话簿.dat",ios::out|ios::binary); if(!outfile) { cout<<"打开文件失败!\n"; return ; } for(;temp;) { outfile.write ((char *)temp,sizeof(*temp)); temp=temp->next ; } outfile.close(); } void telist::change() { Node *temp=search(); cout<<"请输入新的记录:\n"; cout<<"姓名:\n"; cin>>temp->name; cout<<"工作单位:\n"; cin>>temp->workplace; cout<<"家庭电话:\n"; cin>>temp->hometel; cout<<"移动电话:\n"; cin>>temp->mobiletel; store(); }

2008-12-29

电话簿管理(c++编的,适用于初学者)

适用于C++初学者 /************************************************* Copyright (C), 2008- , mekinglong of cumtcs File name:面向对象8(面向对象8.cpp) Author: 计07-2 秦杰 Version: 1.00 Date: 08.11.12 Description:编写程序实现一个简单的电话记录簿,要求记录的个人信息包括: 姓名,单位,家庭电话,移动电话。具体功能如下: 1.创建信息链表并以磁盘文件保存。 2.读取磁盘文件并显示输出所有人的移动电话。 3.按姓名或单位查询家庭电话。 4.通过姓名和单位确定个人,修改其电话信息并存盘. Others: .... Function List: // 主要函数列表,每条记录应包括函数名及功能简要说明 1.main() 完成各种提示与主操作输入输出 History: <author> <time> <version > <desc> *****************************************************/ #include <iostream> #include <assert.h> #include <string> #include <cstring> #include <fstream> #include <iomanip> using namespace std; class telist; class Node { private: char name[30]; char workplace[50]; char hometel[50]; char mobiletel[50]; Node *next; public: friend class telist; friend void load(telist&); }; class telist { private: Node *head; Node *tail; public: telist() { head=tail=NULL; } telist(Node* h,Node *t):tail(t),head(h){} void add(); void del(); void show(); Node* search(); void change(); void store(); Node* find1(); Node* find2(); friend void load(telist&); }; void operate(string ,telist &); void load(telist &); int main() { system("cls"); cout<<"欢迎使用电话簿管理系统:\n"; telist tele; load(tele); string strord; do { cout<<"输入你的操作:\n"; cout<<"1.加入新的电话记录。\n"; cout<<"2.显示输出所有人的移动电话\n"; cout<<"3.按姓名或单位查询家庭电话\n"; cout<<"4.通过姓名和单位确定个人,修改其电话信息并存盘.\n"; cout<<"5.删除一个人信息并存盘。\n"; cout<<"0.退出程序。\n"; cin>>strord; operate(strord,tele); system("cls"); }while(strord!="0") ; system("pause"); system("cls"); return 0; } void operate(string str,telist &t) { if(str=="1") t.add(); else if(str=="2") t.show(); else if(str=="3") t.search(); else if(str=="4") t.change(); else if(str=="5") t.del(); else if(str=="0") t.store(); else cout<<"输入错误!\n"; system("pause"); } void load(telist &t) { ifstream infile("电话簿.dat",ios::in|ios::binary); if(infile == NULL) { cerr<<"打开电话簿失败!!\n"; t.head=t.tail=NULL; return; } if(!infile.eof()) { cout<<"没有数据\n"; t.head=t.tail=NULL; return ; } Node *temp=new Node; t.head=temp; Node *temp2; infile.read ((char*)temp,sizeof(Node)); while(!infile.eof()||temp->next==NULL) // { temp->next=new Node; temp2=temp; temp=temp->next; infile.read ((char*)temp,sizeof(*temp)); t.tail=temp; } temp->next=NULL; delete(temp); t.tail=temp2; t.tail->next=NULL; // delete temp; assert(t.tail->next==NULL); infile.close(); // delete infile; } void telist::add() { if(head==tail&&tail==NULL) { Node * newnode; newnode=head=tail=new Node; if(!newnode) { cout<<"警告:内存分配失败!\n"; return; }//if cout<<"姓名:\n"; cin>>newnode->name; cout<<"工作单位:\n"; cin>>newnode->workplace; cout<<"家庭电话:\n"; cin>>newnode->hometel; cout<<"移动电话:\n"; cin>>newnode->mobiletel; newnode->next=NULL; }//if else{ Node *temp; temp=new Node; tail->next = temp; if(!temp) { cout<<"警告:内存分配失败!\n"; return; } cout<<"姓名:\n"; cin>>temp->name; cout<<"工作单位:\n"; cin>>temp->workplace; cout<<"家庭电话:\n"; cin>>temp->hometel; cout<<"移动电话:\n"; cin>>temp->mobiletel; temp->next=NULL; tail=temp; }//else } void telist::del() { cout<<"先确定你要删除的人:\n"; Node *temp=search(); Node *p=head; if(temp==NULL) { cout<<"没找到要找的人!\n"; return ; } if(p==temp) { cout<<"确定删除?(y或n)"; char ord1; cin>>ord1; if(ord1=='N'||ord1=='n') return; if(ord1=='Y'||ord1=='y') { head=head->next; if(p==tail) tail=NULL;//wenti zaizheli } } else { for(;(p->next)!=temp;) { p=p->next; } cout<<"确定删除?(y或n)"; char ord; cin>>ord; if(ord=='N'||ord=='n')return; if(ord=='Y'||ord=='y')//if1 { if(temp==tail)//if2 { delete temp; tail=p; }//if2 else { p->next=temp->next; delete temp; }//else }//if1 }//else store(); }//del void telist::show() { Node *temp=head; for(;temp!=NULL;) { cout<<setw(15)<<temp->name<<setw(15)<<temp->workplace; cout<<setw(15)<<temp->hometel<<setw(15)<<temp->mobiletel<<endl; temp=temp->next; } return; } Node* telist::search() { // char sname[30]; // char sworkplace[50]; int ord; cout<<"按照什么查询?\n"; cout<<"1.名字。\n"; cout<<"2.工作单位。\n"; cin>>ord; for(;!cin;) { cout<<"error!"; cin>>ord; } switch(ord) { case 1:return(find1());break; case 2:return(find2());break; default:cout<<"警告:操作错误!\n";return 0; } } Node* telist::find1() { char sn[30]; cout<<"请输入姓名:\n"; cin>>sn; cout<<endl; Node *temp=head; for(;temp;temp=temp->next) { if(!strcmp(sn,temp->name)) { cout<<setw(15)<<temp->name<<setw(15)<<temp->workplace; cout<<setw(15)<<temp->hometel<<setw(15)<<temp->mobiletel<<endl; return temp; } if(temp->next==NULL) { cout<<"NO FIND!\n"; return NULL; } else return NULL; } } Node* telist::find2() { char sw[50]; cout<<"请输入工作单位:\n"; cin>>sw; cout<<endl; Node *temp=head; for(;temp;temp=temp->next) { if(!strcmp(sw,temp->workplace)) { cout<<setw(15)<<temp->name<<setw(15)<<temp->workplace; cout<<setw(15)<<temp->hometel<<setw(15)<<temp->mobiletel<<endl; return temp; break; } if(temp->next==NULL) { cout<<"NO FIND!\n"; return NULL; } else return NULL; } } void telist::store() { Node * temp=head; ofstream outfile("电话簿.dat",ios::out|ios::binary); if(!outfile) { cout<<"打开文件失败!\n"; return ; } for(;temp;) { outfile.write ((char *)temp,sizeof(*temp)); temp=temp->next ; } outfile.close(); } void telist::change() { Node *temp=search(); cout<<"请输入新的记录:\n"; cout<<"姓名:\n"; cin>>temp->name; cout<<"工作单位:\n"; cin>>temp->workplace; cout<<"家庭电话:\n"; cin>>temp->hometel; cout<<"移动电话:\n"; cin>>temp->mobiletel; store(); }

2008-12-29

空空如也

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

TA关注的人

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