通讯录源代码
手机通讯录开发源代码

设计开发源代码1.AddContactsActivity类package .demo.pr3;import android.app.Activity;import android.os.Bundle;import android.view.Menu;import android.view.MenuItem;import android.widget.EditText;import android.widget.Toast;import .demo.pr3.datax.ContactsTable;import er;/*增加记录操作界面*/public class AddContactsActivity extends Activity { private EditText nameEditText; //输入框private EditText mobileEditText; //手机输入框private EditText qqEditText; //qqprivate EditText danweiEditText; //单位private EditText addressEditText; //地址Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(yout.edit);setTitle("添加联系人");//从已设置的页面布局查找对应的控件nameEditText=(EditText)findViewById();mobileEditText=(EditText)findViewById(R.id.mobile); danweiEditText=(EditText)findViewById(R.id.danwei); qqEditText=(EditText)findViewById(R.id.qq);addressEditText=(EditText)findViewById(R.id.address); }/*创建菜单 */public boolean onCreateOptionsMenu(Menu menu) {menu.add(Menu.NONE,1, Menu.NONE, "保存");menu.add(Menu.NONE,2, Menu.NONE, "返回");return super.onCreateOptionsMenu(menu);}/* 菜单事件*/public boolean onOptionsItemSelected(MenuItem item){ // TODO Auto-generated method stubswitch (item.getItemId()) {case 1://保存if(!nameEditText.getText().toString().equals("")){User user=new User();user.setName(nameEditText.getText().toString());user.setMoblie(mobileEditText.getText().toString());user.setDanwei(danweiEditText.getText().toString());user.setQq(qqEditText.getText().toString());user.setAddress(addressEditText.getText().toString());ContactsTable ct=new ContactsTable(AddContactsActivity.this);if(ct.addData(user)){Toast.makeText(AddContactsActivity.this, "添加成功!",Toast.LENGTH_SHORT).show();finish();}else{Toast.makeText(AddContactsActivity.this, "添加失败!",Toast.LENGTH_SHORT).show();}}else{Toast.makeText(AddContactsActivity.this, "请先输入数据!",Toast.LENGTH_SHORT).show();}break;case 2://返回finish();break;default:break;}return super.onOptionsItemSelected(item);}}2. ContactsMessageActivity类package .demo.pr3;import android.app.Activity;import android.os.Bundle;import android.view.Menu;import android.view.MenuItem;import android.widget.TextView;import .demo.pr3.datax.ContactsTable;import er;/*显示联系人界面 */public class ContactsMessageActivity extends Activity { private TextView nameTextView; //输入框private TextView mobileTextView; //手机输入框private TextView qqTextView; //qqprivate TextView danweiTextView; //单位private TextView addressTextView; //地址private User user; //修改的联系人Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(yout.message);setTitle("联系人信息");//从已设置的页面布局查找对应的控件nameTextView=(TextView)findViewById();mobileTextView=(TextView)findViewById(R.id.mobile); danweiTextView=(TextView)findViewById(R.id.danwei); qqTextView=(TextView)findViewById(R.id.qq);addressTextView=(TextView)findViewById(R.id.address);//将要修改的联系人数据付值到用户界面显示Bundle localBundle = getIntent().getExtras();int id=localBundle.getInt("user_ID");ContactsTable ct=new ContactsTable(this);user =ct.getUserByID(id);nameTextView.setText(":"+user.getName());mobileTextView.setText(":"+user.getMoblie());qqTextView.setText("QQ:"+user.getQq());danweiTextView.setText("单位:"+user.getDanwei());addressTextView.setText("地址:"+user.getAddress());}/*创建菜单*/public boolean onCreateOptionsMenu(Menu menu) {menu.add(Menu.NONE, 1, Menu.NONE, "返回");return super.onCreateOptionsMenu(menu);}/* 菜单事件 */public boolean onOptionsItemSelected(MenuItem item){// TODO Auto-generated method stubswitch (item.getItemId()) {case 1://返回finish();break;default:break;}return super.onOptionsItemSelected(item);}}3. MyContactsActivity类package .demo.pr3;import android.app.Activity;import android.app.AlertDialog;import android.app.Dialog;import android.app.AlertDialog.Builder;import android.content.ContentUris;import android.content.ContentValues;import android.content.Context;import android.content.DialogInterface;import android.content.Intent;import android.graphics.Color;import .Uri;import android.os.Bundle;import android.provider.ContactsContract.RawContacts;import monDataKinds.Phone;import monDataKinds.StructuredName; import android.provider.ContactsContract.Contacts.Data;import android.view.Menu;import android.view.MenuItem;import android.view.View;import android.view.ViewGroup;import android.widget.AdapterView;import android.widget.BaseAdapter;import android.widget.Button;import android.widget.EditText;import android.widget.ListView;import android.widget.TextView;import android.widget.Toast;import android.widget.AdapterView.OnItemClickListener;import .demo.pr3.datax.ContactsTable;import er;/*主界面*/public class MyContactsActivity extends Activity {private ListView listView; //结果列表private BaseAdapter listViewAdapter; //ListView 列表适配器private User users[];//通讯录用户private int selecteItem=0; //当前选择Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(yout.main);setTitle("通讯录");listView = (ListView) findViewById(R.id.listView);loadContacts();}/*加载联系人列表*/private void loadContacts(){//获取所以通讯录联系人ContactsTable ct=new ContactsTable(this);users=ct.getAllUser();//listView列表现实适配器listViewAdapter=new BaseAdapter() {Overridepublic View getView(int position,View convertView, ViewGroup parent) {if(convertView==null){TextView textView =new TextView(MyContactsActivity.this);textView.setTextSize(22);convertView=textView;}String moblie=users[position].getMoblie()==null?"":users[position].getMoblie();((TextView)convertView).setText(users[position].getName()+"---"+moblie);if(position==selecteItem){convertView.setBackgroundColor(Color.YELLOW);}else{convertView.setBackgroundColor(0);}return convertView;}Overridepublic long getItemId(int position) {return position;}Overridepublic Object getItem(int position) {return users[position];}Overridepublic int getCount() {return users.length;}};//设置listView控件的适配器listView.setAdapter(listViewAdapter);listView.setOnItemClickListener(new OnItemClickListener() {Overridepublic void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {// TODO Auto-generated method stub//记录点击列selecteItem=arg2;//刷新列表listViewAdapter.notifyDataSetChanged();}});}/*创建菜单*/public boolean onCreateOptionsMenu(Menu menu) {menu.add(Menu.NONE, 1, Menu.NONE, "添加");menu.add(Menu.NONE, 2, Menu.NONE, "编辑");menu.add(Menu.NONE, 3, Menu.NONE, "查看信息");menu.add(Menu.NONE, 4, Menu.NONE, "删除");menu.add(Menu.NONE, 5, Menu.NONE, "查询");menu.add(Menu.NONE, 6, Menu.NONE, "导入到手机薄");menu.add(Menu.NONE, 7, Menu.NONE, "退出");return super.onCreateOptionsMenu(menu);}/*菜单事件*/public boolean onOptionsItemSelected(MenuItem item){// TODO Auto-generated method stubswitch (item.getItemId()) {case 1://添加Intent intent = new Intent(MyContactsActivity.this,AddContactsActivity.class);startActivity(intent);break;case 2://编辑if(users[selecteItem].getId_DB()>0)//根据数据库ID判断当前记录是否可以操作{intent = new Intent(MyContactsActivity.this,UpdateContactsActivity.class);intent.putExtra("user_ID", users[selecteItem].getId_DB());startActivity(intent);}else{Toast.makeText(this, "无结果记录,无法操作!",Toast.LENGTH_SHORT).show();}break;case 3://查看信息if(users[selecteItem].getId_DB()>0){intent = new Intent(MyContactsActivity.this,ContactsMessageActivity.class);intent.putExtra("user_ID", users[selecteItem].getId_DB());startActivity(intent);}else{Toast.makeText(this, "无结果记录,无法操作!",Toast.LENGTH_SHORT).show();}break;case 4://删除if(users[selecteItem].getId_DB()>0){delete();}else{Toast.makeText(this, "无结果记录,无法操作!",Toast.LENGTH_SHORT).show();}break;case 5://查询new FindDialog(this).show();break;case 6://导入到手机薄if(users[selecteItem].getId_DB()>0){importPhone(users[selecteItem].getName(),users[selecteItem].getMoblie());Toast.makeText(this, "已经成功导入‘"+users[selecteItem].getName()+"’到手机薄!",Toast.LENGTH_SHORT).show();}else{Toast.makeText(this, "无结果记录,无法操作!",Toast.LENGTH_SHORT).show();}break;case 7://退出finish();break;default:break;}return super.onOptionsItemSelected(item);}Overrideprotected void onResume() {// TODO Auto-generated method stubsuper.onResume();//重新加载数据ContactsTable ct=new ContactsTable(this);users=ct.getAllUser();//刷新列表listViewAdapter.notifyDataSetChanged();}/*查询*/public class FindDialog extends Dialog{public FindDialog(Context context) {super(context);}protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(yout.find);setTitle("联系人查询");Button find=(Button)findViewById(R.id.find);Button cancel=(Button)findViewById(R.id.cancel);find.setOnClickListener(new View.OnClickListener() {Overridepublic void onClick(View v) {// TODO Auto-generated method stubEditText value=(EditText)findViewById(R.id.value);ContactsTable ct=new ContactsTable(MyContactsActivity.this);users=ct.findUserByKey(value.getText().toString());for(int i=0;i<users.length;i++){System.out.println("是"+users[i].getName()+",是" +users[i].getMoblie());}listViewAdapter.notifyDataSetChanged();selecteItem=0;dismiss();}});cancel.setOnClickListener(new View.OnClickListener() {Overridepublic void onClick(View v) {// TODO Auto-generated method stubdismiss();}});}}/*删除联系人*/public void delete(){Builder alert = new AlertDialog.Builder(this);alert.setTitle("系统信息");alert.setMessage("是否要删除联系人?");alert.setPositiveButton("是",new DialogInterface.OnClickListener() {public void onClick(DialogInterface dialog, int whichButton) { ContactsTable ct=new ContactsTable(MyContactsActivity.this);//删除联系人信息if(ct.deleteByUser(users[selecteItem])){//重新获取数据users=ct.getAllUser();//刷新列表listViewAdapter.notifyDataSetChanged();selecteItem=0;Toast.makeText(MyContactsActivity.this, "删除成功!",Toast.LENGTH_SHORT).show();}else{Toast.makeText(MyContactsActivity.this, "删除失败!",Toast.LENGTH_SHORT).show();}}});alert.setNegativeButton("否",new DialogInterface.OnClickListener() {public void onClick(DialogInterface dialog, int whichButton) {}});alert.show();}///导入到手机薄public void importPhone(String name,String phone){//系统通信录ContentProvider的URIUri phoneURL=android.provider.ContactsContract.Data.CONTENT_URI;ContentValues values = new ContentValues();//首先向RawContacts.CONTENT_URI执行一个空值插入,目的是获取系统返回的rawContactIdUri rawContactUri = this.getContentResolver().insert(RawContacts.CONTENT_URI, values);long rawContactId = ContentUris.parseId(rawContactUri);//往data表插入数据values.clear();values.put(Data.RAW_CONTACT_ID, rawContactId);values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);values.put(StructuredName.GIVEN_NAME, name);this.getContentResolver().insert(phoneURL, values);//往data表插入数据values.clear();values.put(Data.RAW_CONTACT_ID, rawContactId);values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);values.put(Phone.NUMBER, phone);values.put(Phone.TYPE, Phone.TYPE_MOBILE);this.getContentResolver().insert(phoneURL, values);}}4. UpdateContactsActivity类package .demo.pr3;import android.app.Activity;import android.os.Bundle;import android.view.Menu;import android.view.MenuItem;import android.widget.EditText;import android.widget.Toast;import .demo.pr3.datax.ContactsTable;import er;/*修改记录操作界面*/public class UpdateContactsActivity extends Activity {/** Called when the activity is first created. */ private EditText nameEditText; //输入框private EditText mobileEditText; //手机输入框private EditText qqEditText; //qqprivate EditText danweiEditText; //单位private EditText addressEditText; //地址private User user; //修改的联系人Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(yout.edit);setTitle("修改联系人");//从已设置的页面布局查找对应的控件nameEditText=(EditText)findViewById();mobileEditText=(EditText)findViewById(R.id.mobile);danweiEditText=(EditText)findViewById(R.id.danwei);qqEditText=(EditText)findViewById(R.id.qq);addressEditText=(EditText)findViewById(R.id.address);//将要修改的联系人数据赋值到用户界面显示Bundle localBundle = getIntent().getExtras();int id=localBundle.getInt("user_ID");ContactsTable ct=new ContactsTable(this);user =ct.getUserByID(id);nameEditText.setText(user.getName());mobileEditText.setText(user.getMoblie());qqEditText.setText(user.getQq());danweiEditText.setText(user.getDanwei());addressEditText.setText(user.getAddress());}/*** 创建菜单*/public boolean onCreateOptionsMenu(Menu menu) {menu.add(Menu.NONE, 1, Menu.NONE, "保存");menu.add(Menu.NONE, 2, Menu.NONE, "返回");return super.onCreateOptionsMenu(menu);}/*** 菜单事件*/public boolean onOptionsItemSelected(MenuItem item){// TODO Auto-generated method stubswitch (item.getItemId()) {case 1://保存if(!nameEditText.getText().toString().equals("")){user.setName(nameEditText.getText().toString());user.setMoblie(mobileEditText.getText().toString());user.setDanwei(danweiEditText.getText().toString());user.setQq(qqEditText.getText().toString());user.setAddress(addressEditText.getText().toString());ContactsTable ct=new ContactsTable(UpdateContactsActivity.this);//修改数据库联系人信息if(ct.updateUser(user)){Toast.makeText(UpdateContactsActivity.this, "修改成功!",Toast.LENGTH_SHORT).show();}else{Toast.makeText(UpdateContactsActivity.this, "修改失败!",Toast.LENGTH_SHORT).show();}}else{Toast.makeText(UpdateContactsActivity.this, "数据不能为空!",Toast.LENGTH_SHORT).show();}break;case 2://返回finish();break;default:break;}return super.onOptionsItemSelected(item);}}。
通讯录管理系统调试源代码

通讯录管理系统调试源代码预览说明:预览图片所展示的格式为文档的源格式展示,下载源文件没有水印,内容可编辑和复制#include#include#include#include#includeusing namespace std;#define FILENAME "C:\\\\phonebook.txt"class Person{public:string name;string sex;string address;stringtel;stringshuxing;Person(string na){name=na;}Person(string na,stringse,stringadd,stringte,stringsx){name=na;sex=se;address=add;tel=te;shuxing=sx;}void display(){cout<<name<<" "<<address<<"="" "<<sex<<"="" "<<shuxing<<endl;<="" "<<tel<<"="" p="">}void add_Person1();void add_Person2();voidlist_Person();void Reach();voiddelete_Person();voiddisplay_diff();voidrenew_Person();};int main(){Person person1("hh");loop:cout<<"\★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\"<<endl;< p="">cout<<"\★★**********************欢迎使用通讯录系统******************* ★★\"<<endl;< p="">cout<<"\★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\"<<endl;< p="">cout<<"\★★************************************************* ***********★★"<<endl;< p="">cout<<"\★★ 1.查看所有联系人2.查找联系人3.添加联系人★★\"<<endl;< p="">cout<<"\★★************************************************* ***********★★\"<<endl;< p="">cout<<"\★★ 4.删除联系人5.修改联系人6.显示类别联系人★★\"<<endl;< p="">cout<<"\★★************************************************* ***********★★\"<<endl;< p="">cout<<"\★★7.退出程序★★\"<<endl;< p="">cout<<"\★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\"<<endl;< p="">cout<<"\ 开发者:"<<"黄龙吉"<<" "<<"张帆"<<" "<<"陈续旭"<<" "<<"程传奇"<<endl;< p="">cout<<"请输入菜单选项:";int a;do{cin>>a;if(a<0||a>8)cout<<"输入有误请重新输入!(1-7)"<<endl;< p=""> } while(a<0||a>8);switch(a){case 1: //显示所有联系人{system("cls");person1.list_Person();system("pause");system("cls");break;}case 2: //按姓名搜索 {system("cls");person1.Reach();system("pause");system("cls");break;}case 3: //添加联系人 { system("cls");person1.add_Person2();system("pause");system("cls");break;}case 4: //删除联系人{ system("cls");person1.delete_Person();system("pause");system("cls");break;}case 5: //修改联系人信息 { system("cls"); person1.renew_Person();system("pause");system("cls");break;}case 6: //按类别显示{ system("cls"); person1.display_diff();system("pause");system("cls");break;}case 7:{//退出break;}default:break;}if (a!=7){goto loop;}return 0;}void Person::add_Person1(){ofstreamfout;fout.open(FILENAME,ios::app);//文件不存在时会主动创建if (fout.fail()){cerr<<"open file with write error"<<endl;< p="">}fout<<name<<" "<<address<<"="" "<<sex<<"="" "<<shuxing<<endl;<="" "<<tel<<"="" p="">fout.close();}void Person::add_Person2(){string name;string sex;string address;stringtel;stringshuxing;ofstreamfout;fout.open(FILENAME,ios::app);//文件不存在时会主动创建if (fout.fail()){cerr<<"open file with write error"<<endl;< p="">}cout<<"请输入姓名:"<<endl;< p="">cin>>name;cout<<"请输入性别:"<<endl;< p="">cin>>sex;cout<<"请输入地址:"<<endl;< p="">cin>>address;cout<<"请输入电话:"<<endl;< p="">cin>>tel;cout<<"请输入属性:"<<endl;< p="">cin>>shuxing;fout<<setw(19)<<left<<name<<setw(5)<<left<<sex<<set w(13)<<left<<<setw(14)<<left<<tel<<setw(10)<<left<<shuxi ng<<endl;<="" p="">fout.close();}void Person::list_Person(){ //全部显示记录//read from fileifstream fin(FILENAME);if (fin.fail()){cerr<< "open file with read error" <<endl;< p="">_exit(-127);}//////////////////////////string s;//存储返回的字符串,即一行的内容//fin.seekg(20,ios::cur);cout<<"================================= ===================="<<endl;< p="">cout<<setw(19)<<left<<"姓名"<<setw(8)<<left<<"性别"<<setw(14)<<left<<"地址"<<setw(9)<<left<<"电话"<<setw(15)<<left<<"属性"<<endl<<endl;< p="">while(getline(fin,s)){//cout<<s.length()<<endl;< p="">cout<<s<<endl;< p="">}cout<<"================================= ===================="<<="" p="">}void Person::Reach(){ //查找记录ifstreaminput_file;char h[100];string s;string name;cout<<"请输入要查找人的姓名:"<<endl;< p="">cin>>name;input_file.open(FILENAME);if(!input_file){cout<<"Codefile.txt can't open file!"<<endl;< p="">return ;}int flag=0;while(input_file>>h){ //使用文件读取来判断文件是否到末尾//字符串运算使用双等于来比较比使用函数更方便if(h==name){cout<< h;getline(input_file,s);cout<<s<<endl;< p="">}else{flag=1;}}if(flag)cout<<"对不起通讯录中没有"+name+"的信息!"<<endl;< p="">input_file.close();//在c++中字符数组可以直接跟字符串作比较}void Person::delete_Person() //删除记录{ifstream fin(FILENAME);ofstreamfout("temp.txt");if (fin.fail()){cerr<< "open file with read error" <<endl;< p="">_exit(-127);}charch;//fin.seekg(20,ios::cur);while(fin.get(ch))//cout<<s.length()<<endl;< p="">fout.put(ch);cout<<="">cout<<"================================= ===================="<<="" p="">fout.close();ifstreamfinfile("temp.txt");ofstreamfoutfile(FILENAME);char h[100];string s;string name;cout<<"请输入要删除人的姓名:"<<endl;< p="">cin>>name;string name1;if(!finfile){cout<<"Codefile.txt can't open file!"<<endl;< p="">return ;}int flag=0;while(finfile>>h){ //使用文件读取来判断文件是否到末尾//字符串运算使用双等于来比较比使用函数更方便if(h!=name){foutfile<<h<<" ";<="" p="">getline(finfile,s);foutfile<<s<<endl;< p="">}else{flag=1;name1=name;getline(finfile,s);}}if(flag==1)cout<<"联系人"+name1+"已经被删除!"<<endl;< p=""> elsecout<<"对不起通讯录中无联系人"+name+"!"<<endl;< p=""> }void Person::renew_Person(){ifstream fin(FILENAME);ofstreamfout("temp.txt");if (fin.fail()){cerr<< "open file with read error" <<endl;< p="">_exit(-127);}charch;//fin.seekg(20,ios::cur);while(fin.get(ch))//cout<<s.length()<<endl;< p="">fout.put(ch);cout<<="">cout<<"================================= ===================="<<="" p="">fout.close();ifstreamfinfile("temp.txt");ofstreamfoutfile(FILENAME);char h[100];string s;string name;cout<<"请输入要修改的姓名:"<<endl;< p="">cin>>name;string name1;int flag;if(!finfile){cout<<"Codefile.txt can't open file!"<<endl;< p="">return ;}while(finfile>>h){ //使用文件读取来判断文件是否到末尾//字符串运算使用双等于来比较比使用函数更方便if(h!=name){foutfile<<h;< p="">getline(finfile,s);foutfile<<s<<endl;< p="">}else{flag=1;getline(finfile,s);string name;string sex;stringtel;string address;stringshuxing;cout<<"请输入记录:"<<endl;< p="">cout<<"姓名:";cin>>name;name1=name;cout<<"性别:";cin>>sex;cout<<"地址:";cin>>address;cout<<"电话:";cin>>tel;cout<<"属性:";cin>>shuxing;foutfile<<setw(19)<<left<<name<<setw(5)<<left<<sex<< setw(13)<<left<<address<<setw(14)<<left<<tel<<setw(10)<<left<<shuxing<< endl;<="" p="">}}if(flag==1)cout<<"联系人"+name+"已经成功修改为"+name1+"!"<<endl;< p="">elsecout<<"通讯录中没有联系人"+name+" 无法进行修改!"<<endl;< p="">}void Person::display_diff(){//分类显示函数ifstreaminfile(FILENAME);char name[100];char sex[100];chartel[100];charsx[100];char add[100];stringshuxing;cout<<"请输入想要查询的类型:"<<endl;< p="">cin>>shuxing;while(infile>>name){infile>>sex;infile>>add;infile>>tel;infile>>sx;if(sx==shuxing){cout<<setw(19)<<left<<name<<setw(5)<<left<<sex<<set w(13)<<left<<<setw(14)<<left<<tel<<setw(10)<<left<<shuxi ng<<endl;<="" p="">}}infile.close();}</setw(19)<<left<<name<<setw(5)<<left<<sex<<setw(13 )<<left<</endl;<></endl;<></endl;<></setw(19)<<left<<name<<setw(5)<<left<<sex<<setw(13 )<<left<<></endl;<></s<<endl;<></h;<></endl;<></endl;<></s.length()<<endl;<></endl;<></endl;<></endl;<></s<<endl;<></h<<"></endl;<></endl;<></s.length()<<endl;<></endl;<></endl;<></s<<endl;<></endl;<></endl;<></s<<endl;<></s.length()<<endl;<></setw(19)<<left<<"姓名"<<setw(8)<<left<<"性别"<<setw(14)<<left<<"地址"<<setw(9)<<left<<"电话"<<setw(15)<<left<<"属性"<<endl<<endl;<></endl;<></endl;<></setw(19)<<left<<name<<setw(5)<<left<<sex<<setw(13 )<<left<</endl;<></endl;<></endl;<></endl;<></endl;<></endl;<></name<<"></endl;<></endl;<></endl;<></endl;<></endl;<></endl;<></endl;<></endl;<></endl;<></endl;<></endl;<></endl;<></endl;<></name<<">。
(完整word版)个人通讯录管理系统源代码

个人通讯录管理系统import javax。
swing。
*;import java。
awt.*;import java。
awt.event。
*;import java.io.*;public class TongXunLu {public static void main(String[] args) {new menu();}}class menu implements ActionListener{JMenuItem zengjia,suoyou,beifen,quit,select,del;JFrame f;Container con;JMenuBar bar;String str1,str2,str3;JFileChooser fc1 = new JFileChooser();File fc2=new File("D://test。
txt”);menu(){f=new JFrame(”通讯录管理系统");f。
setDefaultCloseOperation(JFrame。
DISPOSE_ON_CLOSE);f。
setSize(500, 400);f。
setLocation(130, 150);con=f。
getContentPane();Color c=Color。
YELLOW ;Font fo=new Font("黑体",Font.BOLD,40); JPanel pan=new JPanel();JLabel lab=new JLabel(”通讯录管理系统");lab.setForeground(c);lab.setFont(fo);pan.add(lab);con。
add(pan);bar=new JMenuBar();f。
setJMenuBar(bar);JMenu menu1=new JMenu("文件"); JMenu menu2 =new JMenu(”查询"); JMenu menu3 =new JMenu("删除");zengjia=new JMenuItem("增加记录");suoyou=new JMenuItem(”所有记录”);beifen=new JMenuItem(”文件备份”);quit=new JMenuItem(”退出");select=new JMenuItem(”查询");del=new JMenuItem("删除");menu1.add(zengjia);(完整word版)个人通讯录管理系统源代码menu1。
c语言通讯录源代码打印

c语言通讯录源代码打印Document serial number【LGGKGB-LGG98YT-LGGT8CB-LGUT-#include <>#include <>#include <>#include <>struct person{char name[15];char sex[2];int nianling;long int youbian;char addr[50];char celephone[22];char homephone[22];char company[20];char email[40];long int QQ;}per[500];int num=0;2aame);if(strlen(per[num].name)>15){printf("对不起!您的输入有误!请重新输入");goto name;}printf("\n请输入性别:\n");sex: scanf("%s",&per[num].sex);if(strlen(per[num].sex)==0){printf("对不起!您的输入有误!请重新输入");goto sex;}printf("\n请输入年龄:"); nianling:scanf("%d",&per[num].nianling);if(per[num].nianling<10||per[num].nianling>1 10) {printf("对不起!您的输入有误!请重新输入");goto nianling;}printf("\n请输入邮编\n");youbian: scanf("%d",&per[num].youbian); if(per[num].youbian<10000||per[num].youbia n>999999){printf("对不起!您的输入有误!请重新输入");goto youbian;}printf("\n请输入地址\n");addr: scanf("%s",&per[num].addr);if(strlen(per[num].addr)>50||strlen(per[num].a ddr)<4){printf("对不起!您的输入有误!请重新输入\n");goto addr;}printf("\n请输入手机号码:\n"); celephone:scanf("%s",&per[num].celephone);if(strlen(per[num].celephone)!=11){printf("对不起!您的输入有误!请重新输入\n");goto celephone;}printf("\n请输入家庭电话号码:\n"); homephone:scanf("%s",&per[num].homephone);if(strlen(per[num].homephone)!=11){printf("对不起!您的输入有误!请重新输入\n");goto homephone;}printf("\n请输入公司名称:"); company: scanf("%s",&per[num]pany);if(strlen(per[num]pany)>20||strlen(per[ num]pany)<10){printf("对不起!您的输入有误!请重新输入");goto company;}printf("\n输入电子邮箱:"); email: scanf("%s",&per[num].email);if(strlen(per[num].email)>30||strlen(pe r[num].email)<4){printf("对不起!您的输入有误!请重新输入");goto email;}printf("\n输入QQ号码:");QQ: scanf("%ld",&per[num].QQ);{printf("对不起!您的输入有误!请重新输入");goto QQ;}num++;printf("\n是否继续添加\n");printf("\n请按1和2(1代表继续;2代表不继续)\n");printf("请输入您的选择 ");scanf("%d",&a);if(a==1){goto loop;}else{return;}}void searchmenu()2aelephone,celephone)==0){printf("\n 以下是您查找的联系人的信息 ");printf("\n_______________________ _________");printf("\n名字: %s",per[i].name);printf("\n性别: %s",per[i].sex);printf("\n年龄: %d",per[i].nianling);printf("\n邮编: %ld",per[i].youbian);printf("\n地址: %s",per[i].addr);printf("\n手机号码: %s",per[i].celephone);printf("\n家庭电话号码:%s",per[i].homephone);printf("\n公司名称:%s",per[i]pany);printf("\n电子邮件:%s",per[i].email);printf("\nQQ号码:%ld",per[i].QQ);printf("\n_______________________ _________");printf("\n请按任意数字键返回主菜单");mark++;scanf("%d",&j);return;}}if (mark==0){printf("\n对不起!没有该联系人的信息!");printf("\n请按任意数字键返回主菜单");scanf("%d",&j);return;}}void searchbyname()ame,name)==0){findmark++;printf("\n\t\t 以下是您查找的联系人的信息 ");printf("\n\t\t_____________________ ___________");printf("\n\t\t名字: %s",per[i].name);printf("\n\t\t性别: %s",per[i].sex);printf("\n\t\t年龄: %d",per[i].nianling);printf("\n\t\t邮编: %ld",per[i].youbian);printf("\n\t\t地址: %s",per[i].addr);printf("\n\t\t手机号码: %s",per[i].celephone);printf("\n\t\t家庭电话号码:%s",per[i].homephone);printf("\n\t\t公司名称:%s",per[i]pany);printf("\n\t\t电子邮件:%s",per[i].email);printf("\n\t\tQQ号码:%ld",per[i].QQ);printf("\n\t\t_____________________ ___________");if ((i+1)<num){printf("\n是否继续查找相同名字的联系人的信息(1代表继续;2代表不继续)");scanf("%d",&j);if (j==1){a=i;mark++;continue;}elsebreak;}else{printf("\n请按任意数字键返回主菜单");scanf("%d",&j);return;}}}if(mark!=0){printf("\n对不起! 没有相同名字的该联系人的信息!!");printf("\n请按任意数字键返回主菜单");scanf("%d",&j);return;}else if(findmark==0){printf("\n对不起!没有该联系人的信息!");printf("\n请按任意数字键返回主菜单");scanf("%d",&j);return;}}voidsearchbyhomephone()omephone,homephone) ==0){printf("\n\t\t 以下是您要查找的联系人的信息");printf("\n\t\t_____________________ ___________");printf("\n\t\t名字: %s",per[i].name);printf("\n\t\t性别: %s",per[i].sex);printf("\n\t\t年龄: %d",per[i].nianling);printf("\n\t\t邮编: %ld",per[i].youbian);printf("\n\t\t地址: %s",per[i].addr);printf("\n\t\t手机号码: %s",per[i].celephone);printf("\n\t\t家庭电话号码:%s",per[i].homephone);printf("\n\t\t公司名称:%s",per[i]pany);printf("\n\t\t电子邮件:%s",per[i].email);printf("\n\t\tQQ号码:%ld",per[i].QQ);printf("\n\t\t_____________________ ___________");printf("\n\t\t请按任意数字键返回主菜单");mark++;scanf("%d",&j);return;}}if (mark==0){printf("\n\t\t对不起!没有该联系人的信息!");printf("\n\t\t请按任意数字键返回主菜单");scanf("%d",&j);return;}}void searchbyqq()Q==QQ){printf("\n\t\t 以下是您查找的联系人的信息");printf("\n\t\t_____________________ ___________");printf("\n\t\t名字: %s",per[i].name);printf("\n\t\t性别: %s",per[i].sex);printf("\n\t\t年龄: %d",per[i].nianling);printf("\n\t\t邮编: %ld",per[i].youbian);printf("\n\t\t地址: %s",per[i].addr);printf("\n\t\t手机号码: %s",per[i].celephone);printf("\n\t\t家庭电话号码:%s",per[i].homephone);printf("\n\t\t公司名称:%s",per[i]pany);printf("\n\t\t电子邮件:%s",per[i].email);printf("\n\t\tQQ号码:%ld",per[i].QQ);printf("\n\t\t_____________________ ___________");printf("\n\t\t请按任意数字键返回主菜单");mark++;scanf("%d",&j);return;}}if (mark==0){printf("\n\t\t对不起!没有该联系人的信息!");printf("\n\t\t请按任意数字键返回主菜单");scanf("%d",&j);return;} }void deletemenu()ame,name)==0){printf("\n\t\t以下是您要删除的联系人的纪录:");findmark++;printf("\n\t\t_____________________ ___________");printf("\n\t\t名字: %s",per[i].name);printf("\n\t\t性别: %s",per[i].sex);printf("\n\t\t年龄: %d",per[i].nianling);printf("\n\t\t邮编: %ld",per[i].youbian);printf("\n\t\t地址: %s",per[i].addr);printf("\n\t\t手机号码: %s",per[i].celephone);printf("\n\t\t家庭电话号码:%s",per[i].homephone);printf("\n\t\t公司名称:%s",per[i]pany);printf("\n\t\t电子邮件:%s",per[i].email);printf("\n\t\tQQ号码:%ld",per[i].QQ);printf("\n\t\t_____________________ ___________");printf("\n\t\t是否删除(1代表删除;2代表不删除)\n");printf("\n\t\t请输入您的数字选择: ");scanf("%d",&k);if(k==1){for (j=i;j<num-1;j++) elephone,celephone)==0){deletemark++;printf("\n\t\t以下是您要删除的联系人的纪录:");printf("\n\t\t_____________________ ___________");printf("\n\t\t名字: %s",per[i].name);printf("\n\t\t性别: %s",per[i].sex);printf("\n\t\t年龄: %d",per[i].nianling);printf("\n\t\t邮编: %ld",per[i].youbian);printf("\n\t\t地址: %s",per[i].addr);printf("\n\t\t手机号码: %s",per[i].celephone);printf("\n\t\t家庭电话号码:%s",per[i].homephone);printf("\n\t\t公司名称:%s",per[i]pany);printf("\n\t\t电子邮件:%s",per[i].email);printf("\n\t\tQQ号码:%ld",per[i].QQ);printf("\n\t\t_____________________ ___________");printf("\n\t\t是否删除(1代表删除;2代表不删除)\n");printf(" 请输入您的数字选择: ");scanf("%d",&h);if(h==1){for (j=i;j<num-1;j++) /*纪录移动,从per数组中删除之*/per[j]=per[j+1];num--;printf("\n\t\t删除成功");printf("\n是否继续删除(1代表继续;2代表不继续)\n");printf(" 请输入您的数字选择: ");scanf("%d",&h);if(h==1)deletebycelephone();}}}if(deletemark==0){printf("\n\t\t对不起!没有该联系人的纪录!");printf("\n\t\t是否继续删除(1代表继续;2代表不继续)\n");printf(" 请输入您的数字选择: ");scanf("%d",&m);if(m==1)deletebycelephone();}}void xiugaimenu()3fame,name)==0){printf("\n\t\t以下是您要修改的联系人的纪录:");findmark++;printf("\n\t\t_____________________ ___________");printf("\n\t\t名字: %s",per[i].name);printf("\n\t\t性别: %s",per[i].sex);printf("\n\t\t年龄: %d",per[i].nianling);printf("\n\t\t邮编: %ld",per[i].youbian);printf("\n\t\t地址: %s",per[i].addr);printf("\n\t\t手机号码: %s",per[i].celephone);printf("\n\t\t家庭电话号码:%s",per[i].homephone);printf("\n\t\t公司名称:%s",per[i]pany);printf("\n\t\t电子邮件:%s",per[i].email);printf("\n\t\tQQ号码:%ld",per[i].QQ);printf("\n\t\t________________________________");printf("\n\t\t是否修改(1代表修改;2代表不修改)");printf(" 请输入您的数字选择: ");scanf("%d",&j);if (j==1){xiugaixiangmu(i);xiugaimark++;printf("\n\t\t修改成功");if((i+1)<num){printf("\n\t\t是否继续修改相同姓名的联系人的信息(1代表继续;2代表不继续)");printf(" 请输入您的数字选择: ");scanf("%d",&j);if (j==1){a=i;findmark++; continue;}}printf("\n\t\t是否继续修改(1代表继续;2代表不继续)");printf(" 请输入您的数字选择: ");scanf("%d",&j);if (j==1)xiugaibyname();return;}}}if ((xiugaimark==0)&&(findmark==0)){printf("\n\t\t没有该联系人的纪录");printf("\n\t\t是否继续修改(1代表继续;2代表不继续)");printf(" 请输入您的数字选择: ");scanf("%d",&j);if (j==1)xiugaibyname();return;}else if (findmark!=0){printf("\n\t\t没有重名信息");printf("\n\t\t是否继续修改(1代表继续;2代表不继续)");printf(" 请输入您的数字选择: ");scanf("%d",&j);if (j==1)xiugaibyname();return;}}voidxiugaibycelephone()elephone,celephone)==0){printf("\n\t\t以下是您要修改的联系人的纪录:");findmark++;printf("\n\t\t_____________________ ___________");printf("\n\t\t名字: %s",per[i].name);printf("\n\t\t性别: %s",per[i].sex);printf("\n\t\t年龄: %d",per[i].nianling);printf("\n\t\t邮编: %ld",per[i].youbian);printf("\n\t\t地址: %s",per[i].addr);printf("\n\t\t手机号码: %s",per[i].celephone);printf("\n\t\t家庭电话号码:%s",per[i].homephone);printf("\n\t\t公司名称:%s",per[i]pany);printf("\n\t\t电子邮件:%s",per[i].email);printf("\n\t\tQQ号码:%ld",per[i].QQ);printf("\n\t\t_____________________ ___________");printf("\n\t\t是否修改(1代表修改;2代表不修改)");printf(" 请输入您的数字选择: ");scanf("%d",&j);if (j==1){xiugaixiangmu(i);printf("\n\t\t修改成功");printf("\n\t\t是否继续修改(1代表继续;2代表不继续)");printf(" 请输入您的数字选择: ");scanf("%d",&j);printf(" 请输入您的数字选择: ");if (j==1) xiugaixiangmu(i);break;}}}if (findmark==0){printf("\n\t\t对不起!没有该联系人的纪录!");printf("\n\t\t是否继续修改(1代表继续;2代表不继续)");printf(" 请输入您的数字选择: ");scanf("%d",&j);if (j==1)xiugaibycelephone();return;}}void xiugaixiangmu(int a)elephone);break;case 2:printf("请输入姓名:");scanf("%s",&per[a].name);break;case 3:printf("请输入家庭电话号码:");scanf("%s",&per[a].homephone);break;case 4:printf("请输入QQ号码:");scanf("%s",&per[a].QQ);break;case 5:printf("请输入地址:");scanf("%s",&per[a].addr);break;case 6:printf("请输入邮编:");scanf("%s",&per[a].youbian);break;case 7:printf("请输入email:");scanf("%s",&per[a].email);break;case 8:mainmenu();break;default: printf("对不起!您的输入有误!请重新输入: ");goto loop9;}}void listmenu()ame,per[i-1].name)<0){tmp=per[i];j=i-1;do{per[j+1]=per[j];j--;}while((strcmp,per[j].name)<0&&j>=0));per[j+1]=tmp;}}printf("\n\t\t排序成功,是否显示(1代表继续;2代表不继续)");printf(" 请输入您的数字选择: ");scanf("%d",&k);if (k==1)showall();return;}void listbycelephone()elephone,per[i-1].celephone)<0){tmp=per[i];j=i-1;do{per[j+1]=per[j];j--;}while ((strcmp,per[j].celephone)<0)&&j>=0);per[j+1]=tmp;}}printf("\n\t\t排序成功,是否显示(1代表继续;2代表不继续)");printf(" 请输入您的数字选择: ");scanf("%d",&k);if (k==1)showall();return;}void showall()ame);printf("\n\t\t性别: %s",per[i].sex);printf("\n\t\t年龄: %d",per[i].nianling);printf("\n\t\t邮编: %ld",per[i].youbian);printf("\n\t\t地址: %s",per[i].addr);printf("\n\t\t手机号码: %s",per[i].celephone);printf("\n\t\t家庭电话号码:%s",per[i].homephone);printf("\n\t\t公司名称:%s",per[i]pany);printf("\n\t\t电子邮件:%s",per[i].email);printf("\n\t\tQQ号码:%ld",per[i].QQ);printf("\n\t\t_____________________ ___________");printf("\t\t");if (i+1<num){printf("\n\t\t_____________________ _____");system("pause");}}printf("\n\t\t********************* ***************************");}elseprintf("\n\t\t对不起!通讯录中无任何纪录!");printf("\n\t\t请按任意数字键返回主菜单");scanf("%d",&j);return;}void writetofile()//*写入文件*//{int i,k;system("cls");system("color 84");if ((fp=fopen("","wb"))==NULL){printf("\n\t\t文件打开失败");}for (i=0;i<num;i++){if (fwrite(&per[i],sizeof(struct person),1,fp)!=1){printf("\n\t\t写入文件错误!\n");}}fclose(fp);printf("\n\t\t通讯录文件已保存");printf("\n\t\t请按任意数字键返回主菜单");scanf("%d",&k);return;}void readfromfile()//*读取文件*//{int i,j,k;system("cls");system("color 2b");if((fp=fopen("","rb"))==NULL){printf("\n\t\t********************* *******");printf("\n\t\t* *");printf("\n\t\t* *");printf("\n\t\t* 通讯录文件不存在! *");if((fp=fopen("","wb"))==NULL){printf("\n* 建立失败! *");printf("\n* *");printf("\n* *");printf("\n*********************** *****");exit(0);}else{printf("\n\t\t* 通讯录文件已建立! *");printf("\n\t\t* *");printf("\n\t\t* *");printf("\n\t\t********************* *******");printf("\n\t\t 按任意键进入主菜单 ");printf("\n\t\t 请输入您的数字选择: ");scanf("%d",&k);return;}exit(0);}fseek(fp,0,2); //*文件位置指针移动到文件末尾*//if (ftell(fp)>0) //*文件不为空*//{rewind(fp); //*文件位置指针移动到文件开始位置*//for (num=0;!feof(fp) &&fread(&per[num],sizeof(structperson),1,fp);num++);printf("\n\t\t****************************");printf("\n\t\t* *");printf("\n\t\t* *");printf("\n\t\t* 文件导入成功! *");printf("\n\t\t* *");printf("\n\t\t* *");printf("\n\t\t****************************");printf("\n\t\t 按1显示所有信息,按2回主菜单! "); printf("\t\t 请输入您的数字选择: ");scanf("%d",&j);if(j==1)showall();}else{printf("\n\t\t********************* *******");printf("\n\t\t* *");printf("\n\t\t* *");printf("\n\t\t* 文件导入成功! *");printf("\n\t\t* 通讯录文件中无任何纪录! *");printf("\n\t\t* *");printf("\n\t\t* *");printf("\n\t\t********************* *******");printf("\n\t\t请按任意数字键返回主菜单");scanf("%d",&i);return;}}void deleteall()//*删除所有信息*//{int i,j;system("cls");system("color 50");printf("\n\t\t确认删除\n");printf("请按1和2(1代表确认;2代表不删除)\n ");scanf("%d",&i);if (i==1){fclose(fp);if((fp=fopen("","wb"))==NULL){printf("\n\t\t不能打开文件,删除失败");readfromfile();}num=0;printf("\n\t\t纪录已删除!");printf("\n\t\t请按任意数字键返回主菜单");scanf("%d",&j);return;}}。
个人通讯录管理系统,java源代码

/*** 业务类*/public class PABmanager {/*** 系统启动*/public static void main(String[] args) {Scanner input = new Scanner(System.in);UserDao userDao = new UserDaoImpl();TypeDao typeDao = new TypeDaoImpl();PersonDao personDao = new PersonDaoImpl();String in = input.next();if ("1".equals(in)) {boolean islogin = userDao.login();if(islogin){}else{System.exit(-1);}}else if ("2".equals(in)) {boolean modiFlag = userDao.modify();if(modiFlag){}else{}System.exit(-1);}else{System.exit(-1);}while(true){String in2 = input.next();if ("1".equals(in2)) {while(true){String num = input.next();if ("1".equals(num)) {String lbmc = input.next();String lbsm = input.next();String lbbz = input.next();Type type = new Type(lbmc,lbsm,lbbz);typeDao.createType(type);}else if ("2".equals(num)) {List<Type> types = typeDao.queryType();for (int i = 0; i < types.size(); i++) {Type type =types.get(i);}}else if ("3".equals(num)) {String lbmc = input.next();Type type = new Type(lbmc,null,null);typeDao.deleteType(type);}else if ("4".equals(num)) {break;}else{}}}else if ("2".equals(in2)) {while(true){String num = input.next();if ("1".equals(num)) {String lb = input.next();String xm = input.next();String dh = input.next();String sjh = input.next();String gzdw = input.next();String zz = input.next();String yzbm = input.next();Person person = new Person(lb,xm,dh,sjh,gzdw,zz,yzbm);personDao.createPerson(person);}else if ("2".equals(num)) {String name = input.next();Person p = personDao.queryPerson(name);}else if ("3".equals(num)) {int id = input.nextInt();String item = input.next();String val = input.next();personDao.updatePerson(id,item, val);}else if ("4".equals(num)) {String name = input.next();personDao.deletePerson(name);}else if ("5".equals(num)) {break;}else{}}}else if ("3".equals(in2)) {System.exit(-1);}else{}}}}。
c++写的班级通讯录源代码

#include<fstream>#include<iostream>#include<string>using namespace std;void main();//头文件的声明struct Student//结构定义一个人,存放基本信息{ public://公有的struct Student(){n=0;}void add();//添加void show();//显示void search();//查询void delect();//删除void sort();//排序void load(); //读取文件void save(); //保存通讯录private://私有的int n;string name;//姓名int num;//学号int number;//电话号码char addr[30];//地址char eip[6];//邮编char email[30];//Email}Stu[500];//定义一个类peoplevoid Student::add()//添加函数{cout<<endl;cout<<endl;cout<<endl;system("color 4e");cout<<" ※※※※※※※※※欢迎进入班级通讯录管理系统※※※※※※※※"<<endl<<endl;cout<<" = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = "<<endl;cout<<" ☆信管1班方绍晟☆"<<endl<<endl;cout<<"************************************************************************"<<endl;cout<<" ********** -------------- ※$$ 这是添加功能:$$※-------------*********"<<endl;cout<<"请输入姓名:";cin>>Stu[n].name;cout<<endl;cout<<"学号:";cin>>Stu[n].num;cout<<endl;cout<<"电话号码:";cin>>Stu[n].number;cout<<endl;cout<<"地址:";cin>>Stu[n].addr;cout<<endl;cout<<"邮编:";cin>>Stu[n].eip;cout<<endl;cout<<"Email:";cin>>Stu[n].email;cout<<endl;n++;char m;cout<<"是否继续添加?(y/n)"; //选择cin>>m;if (m=='y')add();}void Student::show()//显示函数{system("color 5e");//颜色调用char l;cout<<endl;cout<<endl;cout<<endl;cout<<" ※※※※※※※※※欢迎进入班级通讯录管理系统※※※※※※※※"<<endl<<endl;cout<<" = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = "<<endl;cout<<" ☆信管1班方绍晟☆"<<endl<<endl;cout<<"************************************************************************"<<endl;cout<<" ****** ---------- ※$$ 这是本通讯录的全部联系人:$$※---------*****"<<endl;cout<<endl;cout<<"姓名学号电话号码地址邮编Email "<<endl;for(int i=0;i<n;i++){cout<<Stu[i].name<<" "<<Stu[i].num<<" "<<Stu[i].number<<""<<Stu[i].addr<<" "<<Stu[i].eip<<" "<<Stu[i].email<<endl;cout<<"----------------------------------------------------"<<endl;}//71cout<<endl;cout<<endl;cout<<"退出请按y/返回请按n"<<endl;cin>>l;if(l=='y')exit(0);//退出程序结构语}void Student::search()//查询函数{system("color 6e");//颜色调用cout<<endl;cout<<endl;cout<<endl;cout<<" ※※※※※※※※※欢迎进入班级通讯录管理系统※※※※※※※※"<<endl<<endl;cout<<" = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = "<<endl;cout<<" ☆信管1班方绍晟☆"<<endl<<endl;cout<<"************************************************************************"<<endl; //80cout<<" ********** -------------- ※$$ 这是查询功能:$$※-------------*********"<<endl;cout<<"************ ------------------<1> 按姓名查询-----------------************"<<endl;cout<<"************ ------------------<2>按学号查询----------------************"<<endl;cout<<"************ ----------------- <3> 按电话号码查询-------------************"<<endl;cout<<"************ ----------------- <4>退出-------------************"<<endl;cout<<"请选择查询方式:";int select,i;cin>>select;switch(select){case 1://按姓名查询{cout<<"请输入想要查询的姓名:"<<endl;string name1;cin>>name1;//输入查询姓名loop:for( i=0;i<=n;i++)//{if(Stu[i].name==name1){cout<<"以下是你要查询的联系人:"<<endl;cout<<"姓名学号电话号码地址邮编Email "<<endl;//100cout<<Stu[i].name<<" "<<Stu[i].num<<" "<<Stu[i].number<<" "<<Stu[i].addr<<" "<<Stu[i].eip<<" "<<Stu[i].email<<endl;cout<<"----------------------------------------------------"<<endl;break;}if(Stu[i].name!=name1)//找不到该联系人{cout<<"该学生不存在,请重新输入。
C语言通讯录源代码IV可运行

#include <stdio.h>#include <stdio.h>#include <string.h>#define maxlen 100struct persons{char name[10];char addr[20];char phnum[10];}persons[maxlen];;;;typedef struct lnode{char name[10];char addr[20];char phnum[10];struct lnode *next;}listnode,*linklist;;;;linklist head=NULL,r=NULL;listnode *s,*p0,*p1,*p2,*p3,*p4,*p5,*p6,*p7; int i;char name1[10],ch;char str1[20];FILE *fp; ;void creat(){ int j;long k;fp=fopen("people.txt","r+t");if(fp!=NULL){for(i=1;i<maxlen;i++){ j=fgetc(fp);if(j==EOF)return;k=i-1;fseek(fp,k*sizeof(struct persons),0);fread(&persons[i],sizeof(struct persons),1,fp); s=(linklist)malloc(sizeof(listnode));strcpy(s->name,persons[i].name);strcpy(s->addr,persons[i].addr);strcpy(s->phnum,persons[i].phnum);if(head==NULL)head=s;elser->next=s;r=s;}}else{ fp=fopen("people.txt","w"); i=1;}};;;void List(){ p1=head;while(p1!=NULL){ printf("\n\n\tname:%s\n",p1->name);printf("\n\n\taddr:%s",p1->addr);printf("\n\n\tphnum:%s",p1->phnum);p1=p1->next;}};;;void Delete(){ printf("\n\n\tplease input the name:");gets(name1); p4=head;if(strcmp(p4->name,name1)==0){ p4=p4->next;head=p4;}else{ while(strcmp(p4->next->name,name1)!=0) p4=p4->next;p5=p4->next;p4->next=p5->next;free(p5);}};;;void Find(){ printf("\n\n\tplease input the name:");p0=head;gets(name1);while(strcmp(name1,p0->name)!=0&&p0!=NULL) p0=p0->next;if(p0==NULL)printf("\n\n\tIt is not exit in the addr-book!");else{ printf("\n\n\tname:%s\n",p0->name);printf("\n\n\taddr:%s",p0->addr);printf("\n\n\tphnum:%s",p0->phnum);}};;;void Input(){ s=(linklist)malloc(sizeof(listnode));printf("\n\n\tplease input the sb's meg:");printf("\n\n\t\tname:");scanf("%s",s->name);printf("\n\n\t\tAddr:");scanf("%s",s->addr);printf("\n\n\t\tphnum:");scanf("%s",s->phnum);if(head==NULL)head=s;elser->next=s;r=s;};;;void Alter(){int j;printf("\n\n\tPlease input the name:");gets(name1);p3=head;while(strcmp(name1,p3->name)!=0&&p3!=NULL)p3=p3->next;if(p3==NULL)printf("\n\n\tIt is not exit in the addr-book!");else{ printf("\n\n\tplease input the new meg!");printf("\n\n\t\tname:");scanf("%s",name1);strcpy(p3->name,name1);printf("\n\n\t\tAddr:");scanf("%s",name1);strcpy(p3->addr,name1);printf("\n\n\t\tphnum:");scanf("%s",name1);strcpy(p3->phnum,name1);}};;;void Save(){ int j;fp=fopen("people.txt","w");for(p2=head,j=0;p2!=NULL;j++,p2=p2->next){ strcpy(persons[j].name,p2->name);strcpy(persons[j].addr,p2->addr);strcpy(persons[j].phnum,p2->phnum);fwrite(&persons[j],sizeof(struct persons),1,fp);}};;;void main(){ creat();do{printf("\n\t***********************************************\n");printf("\n\n\tWELCOME TO USE XIESHENGQING's Address book\n");printf("\n\t**********************************************\n"); printf("\n\n\t\tPlease make a choice below:");printf("\n\t\t1.List all the meg");printf("\n\t\t2.Delete a piece of meg");printf("\n\t\t3.Find a piece of meg");printf("\n\t\t4.Add a piece of meg");printf("\n\t\t5.Alter a piece of meg");printf("\n\t\t6.Save and Quit");printf("\n\t\t7.Create an address book");printf("\n\n\n");printf("\tInput Your Choice:");ch=getche();switch(ch){ case '1': List(); break;case '2': Delete();break;case '3': Find();break;case '4': Input();break;case '5': Alter();break;case '7': Save();break;case '6': creat();fclose(fp);exit(0);break;default:printf("\n\t********************************************\n");printf("\n\t The num should 1-4!!! \n");printf("\n\t********************************************\n");break;}}while(1);}。
个人通讯录管理系统,java源代码

/*** 业务类*/public class PABmanager {/*** 系统启动*/public static void main(String[] args) {Scanner input = new Scanner(System.in);UserDao userDao = new UserDaoImpl();TypeDao typeDao = new TypeDaoImpl();PersonDao personDao = new PersonDaoImpl();String in = input.next();if ("1".equals(in)) {boolean islogin = userDao.login();if(islogin){}else{System.exit(-1);}}else if ("2".equals(in)) {boolean modiFlag = userDao.modify();if(modiFlag){}else{}System.exit(-1);}else{System.exit(-1);}while(true){String in2 = input.next();if ("1".equals(in2)) {while(true){String num = input.next();if ("1".equals(num)) {String lbmc = input.next();String lbsm = input.next();String lbbz = input.next();Type type = new Type(lbmc,lbsm,lbbz);typeDao.createType(type);}else if ("2".equals(num)) {List<Type> types = typeDao.queryType();for (int i = 0; i < types.size(); i++) {Type type =types.get(i);}}else if ("3".equals(num)) {String lbmc = input.next();Type type = new Type(lbmc,null,null);typeDao.deleteType(type);}else if ("4".equals(num)) {break;}else{}}}else if ("2".equals(in2)) {while(true){String num = input.next();if ("1".equals(num)) {String lb = input.next();String xm = input.next();String dh = input.next();String gzdw = input.next();String zz = input.next();String yzbm = input.next();Person person = new Person(lb,xm,dh,sjh,gzdw,zz,yzbm);personDao.createPerson(person);}else if ("2".equals(num)) {String name = input.next();Person p = personDao.queryPerson(name);}else if ("3".equals(num)) {int id = input.nextInt();String item = input.next();String val = input.next();personDao.updatePerson(id,item, val);}else if ("4".equals(num)) {personDao.deletePerson(name);}else if ("5".equals(num)) {break;}else{}}}else if ("3".equals(in2)) {System.exit(-1);}else{}}}}。