用戶登錄系統
基本要求:
1)輸入用戶名和用戶密碼,如果用戶名不存在,或者密碼錯誤,提示重新輸入;
2)根據用戶類型 (管理員、注冊用戶、游客),輸出不同的操作菜單;
3)有刪除賬號的功能以及修改密碼的功能。
4)用戶信息保存在文件中
擴展:
1)在管理員界面可以看到各個用戶的賬號,可以對其賬號進行加鎖與解鎖操作。
2)有相應的圖形界面等,功能越完善可酌情加分。
寒假用c++寫了個用戶登錄系統,參考了@一只快樂的程序猿[Hui] 的學生學籍管理系統(http://www.cnblogs.com/suthui/p/3767252.html)。基本上是依次拷貝成員函數然後增刪一些,也學到了很多東西。
本程序通過三個類:insider(注冊會員)、admin(管理員)、visitor(游客),輸出不同的操作菜單,並將用戶信息保存在文件中。
功能:
1, 注冊用戶可以修改用戶名、修改密碼;
2, 管理員可以顯示、搜索、添加、刪除、加鎖、解鎖用戶;修改用戶密碼;修改管理員名和密碼;加鎖、解鎖管理員。
3, 用戶信息保存在insiderDat.dat中;管理員信息保存在adminDat.dat中。格式為:加鎖狀態 用戶名 密碼,加鎖狀態0表示密碼已加鎖,1表示密碼已上鎖。
4, 初始管理員用戶名和密碼均為admin。
5, 當管理員添加用戶或用戶修改用戶名時,提示用戶名已存在並重新輸入。
1 //寒假應用軟件設計-用戶管理系統
2 #include <iostream>
3 #include <fstream>
4 #include <string>
5 #include <iomanip>
6 using namespace std;
7
8 const int M=100000;
9
10 string user;
11 int I_lockstate[M];
12 string I_name[M];
13 string I_password[M];
14 int A_lockstate;
15 string A_name;
16 string A_password;
17
18 int home();
19 int insider_login();
20 int admin_login();
21 int visitor_login();
22 int Imenu(int);
23 int Amenu(int);
24 int Vmenu(int);
25 string encrypt(string);
26 string decrypt(string);
27 string showw10(string);
28
29 class visitor
30 {
31 private:
32 string Vname;
33 public:
34 int VchangeName(int a)
35 {
36 int i,mark;
37 cout<<"請輸入新登錄名:";
38 cin>>user;cin.sync();
39 cout<<"修改用戶名成功!";
40 getchar();
41 return 0;
42 }
43 };
44
45 class insider
46 {
47 protected:
48 int Ilockstate;
49 string Iname;
50 string Ipassword;
51 public:
52 int IchangeName(int a)
53 {
54 int i,mark,repetition;
55 ifstream infile("insiderDat.dat",ios::in);
56 for(i=0;!infile.eof();i++)
57 infile>>I_lockstate[i]>>I_name[i]>>I_password[i];
58 mark=i;
59 infile.close();
60 cout<<"請輸入新用戶名:";
61 cin>>Iname;cin.sync();
62 while(1)
63 {
64 repetition=1;
65 for(int j=0;j<=i;j++)
66 if(Iname==I_name[j])
67 repetition=0;
68 if(repetition) break;
69 cout<<"用戶名已存在,請重新輸入:";
70 cin>>Iname;cin.sync();
71 }
72 I_name[a]=Iname;
73 user=I_name[a];
74 ofstream outfile("insiderDat.dat",ios::out);
75 for(i=0;i<mark-1;i++)
76 outfile<<I_lockstate[i]<<' '<<I_name[i]<<' '<<I_password[i]<<endl;
77 outfile.close();
78 cout<<"修改用戶名成功!";
79 getchar();
80 return 0;
81 }
82 int IchangePassword(int a)
83 {
84 int i,mark;
85 ifstream infile("insiderDat.dat",ios::in);
86 for(i=0;!infile.eof();i++)
87 infile>>I_lockstate[i]>>I_name[i]>>I_password[i];
88 mark=i;
89 infile.close();
90 cout<<"請輸入新密碼:";
91 cin>>I_password[a];cin.sync();
92 if(!I_lockstate[a])
93 I_password[a]=encrypt(I_password[a]);
94 ofstream outfile("insiderDat.dat",ios::out);
95 for(i=0;i<mark-1;i++)
96 outfile<<I_lockstate[i]<<' '<<I_name[i]<<' '<<I_password[i]<<endl;
97 outfile.close();
98 cout<<"修改密碼成功!";
99 getchar();
100 return 0;
101 }
102 };
103
104 class admin: public insider
105 {
106 private:
107 string Alockstate;
108 string Aname;
109 string Apassword;
110 public:
111 int AchangeName()
112 {
113 cout<<"請輸入管理員新用戶名:";
114 cin>>A_name;cin.sync();
115 user=A_name;
116 ofstream outfile("adminDat.dat",ios::out);
117 outfile<<A_lockstate<<" "<<A_name<<" "<<A_password<<endl;
118 outfile.close();
119 cout<<"修改管理員用戶名成功!";
120 getchar();
121 return 0;
122 }
123 int AchangePassword()
124 {
125 cout<<"請輸入管理員新密碼:";
126 cin>>A_password;cin.sync();
127 if(!A_lockstate)
128 A_password=encrypt(A_password);
129 ofstream outfile("adminDat.dat",ios::out);
130 if(!outfile)
131 {
132 cerr<<"open error!"<<endl;
133 getchar();
134 exit(1);
135 }
136 outfile<<A_lockstate<<" "<<A_name<<" "<<A_password<<endl;
137 outfile.close();
138 cout<<"修改管理員密碼成功!";
139 getchar();
140 return 0;
141 }
142 int Alock()
143 {
144 ifstream infile("adminDat.dat",ios::in);
145 if(!infile)
146 {
147 cerr<<"超級管理員無此功能!";
148 getchar();
149 return 0;
150 }
151 infile.close();
152 if(A_lockstate)
153 {
154 A_lockstate=0;
155 A_password=encrypt(A_password);
156 ofstream outfile("adminDat.dat",ios::out);
157 outfile<<A_lockstate<<' '<<user<<' '<<A_password<<endl;
158 outfile.close();
159 cout<<"加鎖管理員成功!";
160 }
161 else
162 cout<<"管理員已處於加鎖狀態!";
163 getchar();
164 return 0;
165 }
166 int Aunlock()
167 {
168 ifstream infile("adminDat.dat",ios::in);
169 if(!infile)
170 {
171 cerr<<"超級管理員無此功能!";
172 getchar();
173 return 0;
174 }
175 infile.close();
176 if(!A_lockstate)
177 {
178 A_lockstate=1;
179 A_password=decrypt(A_password);
180 ofstream outfile("adminDat.dat",ios::out);
181 outfile<<A_lockstate<<' '<<user<<' '<<A_password<<endl;
182 outfile.close();
183 cout<<"解鎖管理員成功!";
184 }
185 else
186 cout<<"管理員已處於解鎖狀態!";
187 getchar();
188 return 0;
189 }
190 int Iadd()
191 {
192 int i,repetition;
193 ifstream infile("insiderDat.dat",ios::in);
194 if(infile)
195 {
196 for(i=0;!infile.eof();i++)
197 infile>>I_lockstate[i]>>I_name[i]>>I_password[i];
198 cout<<"請輸入用戶名:";
199 cin>>Iname;cin.sync();
200 while(1)
201 {
202 repetition=1;
203 for(int j=0;j<=i;j++)
204 if(Iname==I_name[j])
205 repetition=0;
206 if(repetition) break;
207 cout<<"用戶名已存在,請重新輸入:";
208 cin>>Iname;cin.sync();
209 }
210 }
211 else
212 {
213 cout<<"請輸入用戶名:";
214 cin>>Iname;cin.sync();
215 }
216 infile.close();
217 cout<<"請輸入密碼:";
218 cin>>Ipassword;cin.sync();
219 ofstream outfile("insiderDat.dat",ios::app);
220 outfile<<'1'<<' '<<Iname<<' '<<Ipassword<<endl;
221 outfile.close();
222 cout<<"添加用戶成功!";
223 getchar();
224 }
225 int Idelete()
226 {
227 int mark;
228 int k,i;
229 mark = Ishow();
230 if(mark == 0) return 0;
231 if(mark == 2)
232 {
233 cout<<"刪除失敗!";
234 getchar();
235 return 0;
236 }
237 cout<<"請選擇一個刪除序號【放棄0】:";
238 cin>>k;cin.sync();
239 if(k==0) return 0;
240 while(1)
241 {
242 ofstream outfile("insiderDat.dat",ios::out);
243 if(!outfile)
244 {
245 cerr<<"open error!"<<endl;
246 exit(1);
247 }
248 for(i=0;i<mark-1;i++)
249 if(i!=k-1)
250 outfile<<I_lockstate[i]<<' '<<I_name[i]<<' '<<I_password[i]<<endl;
251 outfile.close();
252 cout<<"刪除成功!";
253 getchar();
254 return 0;
255 }
256 }
257 int IchangeIPassword()
258 {
259 int mark;
260 int k;
261 mark = Ishow();
262 if(mark == 0) return 0;
263 cout<<"請選擇一個序號進行修改【放棄0】:";
264 cin>>k;cin.sync();
265 if(k)
266 {
267 cout<<"請輸入新密碼:";
268 cin>>I_password[k-1];cin.sync();
269 if(!I_lockstate[k-1])
270 I_password[k-1]=encrypt(I_password[k-1]);
271 ofstream outfile("insiderDat.dat",ios::out);
272 for(int i=0;i<mark-1;i++)
273 outfile<<I_lockstate[i]<<' '<<I_name[i]<<' '<<I_password[i]<<endl;
274 outfile.close();
275 cout<<"修改成功!";
276 }
277 getchar();
278 return 0;
279 }
280 int Isearch()
281 {
282 string temp;
283 int i;
284 ifstream infile("insiderDat.dat",ios::in);
285 if(!infile)
286 {
287 cerr<<"當前無用戶!";
288 getchar();
289 return 0;
290 }
291 cout<<"輸入查找的用戶名:";
292 cin>>temp;cin.sync();
293 for(i=0; !infile.eof(); i++)
294 {
295 infile>>I_lockstate[i]>>I_name[i]>>I_password[i];
296 if(I_name[i] == temp)
297 {
298 cout<<"已找到:"<<endl;
299 cout<<"加鎖狀態:"<<setw(10)<<I_lockstate[i]<<endl;
300 cout<<"用戶名: "<<setw(10)<<I_name[i]<<endl;
301 cout<<"密碼: "<<setw(10)<<I_password[i]<<endl;
302 infile.close();
303 system("pause");
304 return 0;
305 }
306 }
307 cout<<"查無此項!";
308 getchar();
309 infile.close();
310 }
311 int Ishow()
312 {
313 int mark,i;
314 ifstream infile("insiderDat.dat",ios::in);
315 if(!infile)
316 {
317 cout<<"當前無用戶!";
318 getchar();
319 return 0;
320 }
321 cout<<" 序號 加鎖狀態 用戶名 密碼"<<endl;
322 for(i=0; !infile.eof(); i++)
323 infile>>I_lockstate[i]>>I_name[i]>>I_password[i];
324 mark=i;
325 for(i=0; i<mark-1;i++)
326 {
327 cout<<setw(10)<<i+1<<' '
328 <<setw(10)<<I_lockstate[i]<<' '
329 <<setw(10)<<showw10(I_name[i])<<' '
330 <<setw(10)<<showw10(I_password[i])<<endl;
331 }
332 infile.close();
333 system("pause");
334 return mark;
335 }
336 int Ilock()
337 {
338 int mark;
339 int k;
340 mark = Ishow();
341 if(mark == 0) return 0;
342 cout<<"請選擇一個序號進行加鎖【放棄0】:";
343 cin>>k;cin.sync();
344 if(k&&k<mark)
345 {
346 if(I_lockstate[k-1]==1)
347 {
348 I_lockstate[k-1]=0;
349 I_password[k-1]=encrypt(I_password[k-1]);
350 ofstream outfile("insiderDat.dat",ios::out);
351 for(int i=0;i<mark-1;i++)
352 outfile<<I_lockstate[i]<<' '<<I_name[i]<<' '<<I_password[i]<<endl;
353 outfile.close();
354 cout<<"加鎖該用戶成功!"<<endl;
355 }
356 else
357 cout<<"該用戶已處於加鎖狀態!"<<endl;
358 }
359 system("pause");
360 return 0;
361 }
362 int Iunlock()
363 {
364 int mark;
365 int k;
366 mark = Ishow();
367 if(mark == 0) return 0;
368 cout<<"請選擇一個序號進行解鎖【放棄0】:";
369 cin>>k;cin.sync();
370 if(k&&k<mark)
371 {
372 if(I_lockstate[k-1]==0)
373 {
374 I_lockstate[k-1]=1;
375 I_password[k-1]=decrypt(I_password[k-1]);
376 ofstream outfile("insiderDat.dat",ios::out);
377 for(int i=0;i<mark-1;i++)
378 outfile<<I_lockstate[i]<<' '<<I_name[i]<<' '<<I_password[i]<<endl;
379 outfile.close();
380 cout<<"解鎖該用戶成功!"<<endl;
381 }
382 else
383 cout<<"該用戶已處於解鎖狀態!"<<endl;
384 }
385 system("pause");
386 return 0;
387 }
388 };
389
390
391
392 int main()
393 {
394 system("color 09");
395 home();
396 return 0;
397 }
398
399 int home()
400 {
401 char n;
402 int Mark;
403 while(1)
404 {
405 system("cls");
406 Mark=1;
407 cout<<"**********************************************************************"<<endl;
408 cout<<"* *"<<endl;
409 cout<<"* ★用戶登錄系統★ *"<<endl;
410 cout<<"* *"<<endl;
411 cout<<"**********************************************************************"<<endl;
412 cout<<"* *"<<endl;
413 cout<<"* 請選擇您的用戶類型 *"<<endl;
414 cout<<"* *"<<endl;
415 cout<<"* 用戶類型 請輸入 *"<<endl;
416 cout<<"* *"<<endl;
417 cout<<"* ◆ 注冊用戶 1 *"<<endl;
418 cout<<"* ◆ 管理員 2 *"<<endl;
419 cout<<"* ◆ 游客 3 *"<<endl;
420 cout<<"* *"<<endl;
421 cout<<"**********************************************************************"<<endl;
422 cout<<"* *"<<endl;
423 cout<<"* 退出管理系統 0 *"<<endl;
424 cout<<"* *"<<endl;
425 cout<<"**********************************************************************"<<endl;
426 cout<<"請選擇功能:";
427 while(Mark)
428 {
429 cin>>n;cin.sync();
430 switch(n)
431 {
432 case '1': Imenu(insider_login());Mark=0;break;
433 case '2': Amenu(admin_login());Mark=0;break;
434 case '3': Vmenu(visitor_login());Mark=0;break;
435 case '0': exit(0);
436 default : cout<<"\n輸入有誤,請重新輸入:";
437 }
438 }
439 }
440 return 0;
441 }
442
443 int insider_login()
444 {
445 string password;
446 system("cls");
447 ifstream infile("insiderDat.dat",ios::in);
448 if(!infile)
449 {
450 cerr<<"\n\n\n\n\n\n 系統未開放使用!";
451 getchar();
452 return -1;
453 }
454 infile.close();
455 cout<<"\n\n\n"<<endl;
456 cout<<" ***********************************"<<endl;
457 cout<<" * *"<<endl;
458 cout<<" * ★用戶登錄系統 ★ *"<<endl;
459 cout<<" * 注冊用戶登錄 *"<<endl;
460 cout<<" ***********************************"<<endl;
461 while(1)
462 {
463 cout<<"\n 用戶名:";
464 cin>>user;cin.sync();
465 cout<<" 密碼:";
466 cin>>password;cin.sync();
467 ifstream infile("insiderDat.dat",ios::in);
468 for(int i=0;!infile.eof();i++)
469 {
470 infile>>I_lockstate[i]>>I_name[i]>>I_password[i];
471 if(user == I_name[i]&&(I_lockstate[i]&&password == I_password[i]||!I_lockstate[i]&&password == decrypt(I_password[i])))
472 {
473 cout<<"\n 登錄成功!";
474 getchar();
475 return i;
476 }
477 }
478 cout<<"\n 用戶名或密碼錯誤..."<<endl;
479 infile.close();
480 }
481 }
482
483 int admin_login()
484 {
485 int i;
486 string password;
487 system("cls");
488 cout<<"\n\n\n"<<endl;
489 cout<<" ***********************************"<<endl;
490 cout<<" * *"<<endl;
491 cout<<" * ★用戶登錄管理系統★ *"<<endl;
492 cout<<" * 管理員登錄 *"<<endl;
493 cout<<" ***********************************"<<endl;
494 ifstream infile("adminDat.dat",ios::in);
495 if(!infile)
496 {
497 A_name="admin";
498 A_lockstate=1;
499 cout<<"\n 超級用戶:";
500 cin>>user; cin.sync();
501 if(user=="admin")
502 {
503 cout<<" 超級密碼:";
504 while(1)
505 {
506 cin>>password;cin.sync();
507 A_password="admin";
508 if(password == A_password)
509 {
510 cout<<"\n 登錄成功!";
511 A_lockstate=1;
512 getchar();
513 return 1;
514 }
515 else
516 cout<<"\n 密碼錯誤請重新輸入:";cin.sync();
517 }
518 }
519 else
520 {
521 system("cls");
522 cerr<<"\n\n\n\n\n\n 無權限使用!";
523 getchar();
524 return 0;
525 }
526 }
527 else
528 {
529 infile.close();
530 while(1)
531 {
532 cout<<"\n 用戶名:";
533 cin>>user;cin.sync();
534 cout<<" 密碼:";
535 cin>>password;cin.sync();
536 ifstream infile("adminDat.dat",ios::in);
537 infile>>A_lockstate>>A_name>>A_password;
538 if(user == A_name&&(A_lockstate&&password == A_password||!A_lockstate&&password == decrypt(A_password)))
539 {
540 cout<<"\n 登錄成功!";
541 getchar();
542 infile.close();
543 return 1;
544 }
545 cout<<"\n 用戶名或密碼錯誤..."<<endl;
546 infile.close();
547 }
548 }
549 return 0;
550 }
551
552 int visitor_login()
553 {
554 user="visitor";
555 return 0;
556 }
557
558 int Imenu(int a)
559 {
560 char n;
561 int mark;
562 if(!(a+1)) return 0;
563 while(1)
564 {
565 system("cls");
566 insider IN_insider;
567 mark=1;
568 cout<<"******************************************************"<<endl;
569 cout<<"* *"<<endl;
570 cout<<"* ★用戶登錄系統★ *"<<endl;
571 cout<<"* 用戶:"<<setw(10)<<showw10(user)<<" *"<<endl;
572 cout<<"* *"<<endl;
573 cout<<"******************************************************"<<endl;
574 cout<<"* ┌--------------------用戶管理-------------------┐*"<<endl;
575 cout<<"* | | *"<<endl;
576 cout<<"* | 功能 請輸入 | *"<<endl;
577 cout<<"* | ◆ 修改用戶名 1 | *"<<endl;
578 cout<<"* | ◆ 修改密碼 2 | *"<<endl;
579 cout<<"* └-----------------------------------------------┘*"<<endl;
580 cout<<"******************************************************"<<endl;
581 cout<<"* ● 返回主界面 h *"<<endl;
582 cout<<"* ● 退出登錄系統 0 *"<<endl;
583 cout<<"******************************************************"<<endl;
584 cout<<"請選擇功能:";
585 while(mark)
586 {
587 cin>>n;cin.sync();
588 switch(n)
589 {
590 case '1':IN_insider.IchangeName(a);mark=0;break;
591 case '2':IN_insider.IchangePassword(a);mark=0;break;
592
593 case 'h':return 0;
594 case '0': exit(0);
595 default : cout<<"\n輸入有誤,請重新輸入:";
596 }
597 }
598 }
599 }
600 int Amenu(int a)
601 {
602 char n;
603 int Mark;
604 if(!a) return 0;
605 while(1)
606 {
607 system("cls");
608 admin AD_admin;
609 Mark=1;
610 cout<<"******************************************************"<<endl;
611 cout<<"* *"<<endl;
612 cout<<"* ★用戶登錄系統★ *"<<endl;
613 cout<<"* 管理員:"<<setw(10)<<showw10(user)<<" *"<<endl;
614 cout<<"* *"<<endl;
615 cout<<"******************************************************"<<endl;
616 cout<<"* ┌--------------------用戶管理-------------------┐*"<<endl;
617 cout<<"* | | *"<<endl;
618 cout<<"* | 功能 請輸入 | *"<<endl;
619 cout<<"* | ◆ 顯示用戶 1 | *"<<endl;
620 cout<<"* | ◆ 查找用戶 2 | *"<<endl;
621 cout<<"* | ◆ 修改用戶 3 | *"<<endl;
622 cout<<"* | ◆ 添加用戶 4 | *"<<endl;
623 cout<<"* | ◆ 刪除用戶 5 | *"<<endl;
624 cout<<"* | ◆ 加鎖用戶 6 | *"<<endl;
625 cout<<"* | ◆ 解鎖用戶 7 | *"<<endl;
626 cout<<"* └-----------------------------------------------┘*"<<endl;
627 cout<<"* ┌-------------------管理員管理------------------┐*"<<endl;
628 cout<<"* | | *"<<endl;
629 cout<<"* | 功能 請輸入 | *"<<endl;
630 cout<<"* | ◆ 修改用戶名 a | *"<<endl;
631 cout<<"* | ◆ 修改密碼 b | *"<<endl;
632 cout<<"* | ◆ 加鎖管理員 c | *"<<endl;
633 cout<<"* | ◆ 解鎖管理員 d | *"<<endl;
634 cout<<"* └-----------------------------------------------┘*"<<endl;
635 cout<<"******************************************************"<<endl;
636 cout<<"* ● 返回主界面 h *"<<endl;
637 cout<<"* ● 退出登錄系統 0 *"<<endl;
638 cout<<"******************************************************"<<endl;
639 cout<<"請選擇功能:";
640 while(Mark)
641 {
642 cin>>n;cin.sync();
643 switch(n)
644 {
645 case '1': AD_admin.Ishow();Mark=0;break;
646 case '2': AD_admin.Isearch();Mark=0;break;
647 case '3': AD_admin.IchangeIPassword();Mark=0;break;
648 case '4': AD_admin.Iadd();Mark=0;break;
649 case '5': AD_admin.Idelete();Mark=0;break;
650 case '6': AD_admin.Ilock();Mark=0;break;
651 case '7': AD_admin.Iunlock();Mark=0;break;
652
653 case 'a': AD_admin.AchangeName();Mark=0;break;
654 case 'b': AD_admin.AchangePassword();Mark=0;break;
655 case 'c': AD_admin.Alock();Mark=0;break;
656 case 'd': AD_admin.Aunlock();Mark=0;break;
657
658 case 'h':return 0;
659 case '0': exit(0);
660 default : cout<<"\n輸入有誤,請重新輸入:";
661 }
662 }
663 }
664 return 0;
665 }
666
667 int Vmenu(int a)
668 {
669 char n;
670 int mark;
671 while(1)
672 {
673 system("cls");
674 visitor VI_visitor;
675 mark=1;
676 cout<<"******************************************************"<<endl;
677 cout<<"* *"<<endl;
678 cout<<"* ★用戶登錄系統★ *"<<endl;
679 cout<<"* 游客:"<<setw(10)<<showw10(user)<<" *"<<endl;
680 cout<<"* *"<<endl;
681 cout<<"******************************************************"<<endl;
682 cout<<"* ┌--------------------游客管理-------------------┐*"<<endl;
683 cout<<"* | | *"<<endl;
684 cout<<"* | 功能 請輸入 | *"<<endl;
685 cout<<"* | ◆ 修改登錄名 1 | *"<<endl;
686 cout<<"* └-----------------------------------------------┘*"<<endl;
687 cout<<"******************************************************"<<endl;
688 cout<<"* ● 返回主界面 h *"<<endl;
689 cout<<"* ● 退出登錄系統 0 *"<<endl;
690 cout<<"******************************************************"<<endl;
691 cout<<"請選擇功能:";
692 while(mark)
693 {
694 cin>>n;cin.sync();
695 switch(n)
696 {
697 case '1':VI_visitor.VchangeName(a);mark=0;break;
698
699 case 'h':return 0;
700 case '0': exit(0);
701 default : cout<<"\n輸入有誤,請重新輸入:";
702 }
703 }
704 }
705 }
706
707 string encrypt(string s)
708 {
709 int len=s.length();
710 for(int i=0;i<len;i++)
711 s[i]=~s[i]+12;
712 return s;
713 }
714
715 string decrypt(string s)
716 {
717 int len=s.length();
718 for(int i=0;i<len;i++)
719 s[i]=~(s[i]-12);
720 return s;
721 }
722
723 string showw10(string s)
724 {
725 int k=s.length();
726 if(k>10)
727 {
728 s.assign(s,0,7);
729 s+="...";
730 }
731 return s;
732 }