1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930
| #include <iostream> #include <fstream> #include <vector> #include <algorithm> #include <string> #include <iomanip> #include <set> using namespace std;
class Song { public: string name; string singer; string author; string composer; string album; string length; string language; string date; int hot; Song() { } Song(string name, string singer, string author, string composer, string album, string length, string language, string date, int hot) { this->name = name; this->singer = singer; this->author = author; this->composer = composer; this->album = album; this->length = length; this->language = language; this->date = date; this->hot = hot; } ~Song() { } void showSongInfo() { cout << left << setw(16) << name; cout << left << setw(10) << singer; cout << left << setw(10) << author; cout << left << setw(10) << composer; cout << left << setw(16) << album; cout << left << setw(10) << length; cout << left << setw(8) << language ; cout << left << setw(14) << date; cout << left << setw(12) << hot << endl; } static void showHeader() { cout << left << setw(16) << "歌曲名"; cout << left << setw(10) << "演唱者"; cout << left << setw(10) << "作词"; cout << left << setw(10) << "作曲"; cout << left << setw(16) << "所属专辑"; cout << left << setw(10) << "歌曲长度"; cout << left << setw(8) << "语言" ; cout << left << setw(14) << "发行日期"; cout << left << setw(12) << "热度" << endl; } };
class SongSystem { public: vector<Song> songs; vector<Song> mySongs;
SongSystem(); SongSystem(vector<Song> songs, vector<Song> mySongs); ~SongSystem(); void init(); void menu(); void readFile(); void writeFile(); void insertList(); void deleteList(); void updateList(); void selectList(); void displaySong(vector<Song>& ss); void displaySong(vector<Song>& ss, int n); void displayList(); void favorites(); void groupList(); void clearList(); };
SongSystem::SongSystem() { }
SongSystem::SongSystem(vector<Song> songs, vector<Song> mySongs) { this->songs = songs; this->mySongs = mySongs; }
SongSystem::~SongSystem() { }
void SongSystem::init() { readFile(); }
void SongSystem::menu() { string sel = "0"; system("cls"); cout << "\t\t\t**********欢迎来到个人乐库管理系统**********" << endl; cout << "\t\t\t你可以进行以下操作:" << endl; cout << "\t\t\t|------------------------------------------|" << endl; cout << "\t\t\t| 1 歌曲添加 |" << endl; cout << "\t\t\t|------------------------------------------|" << endl; cout << "\t\t\t| 2 歌曲删除 |" << endl; cout << "\t\t\t|------------------------------------------|" << endl; cout << "\t\t\t| 3 歌曲修改 |" << endl; cout << "\t\t\t|------------------------------------------|" << endl; cout << "\t\t\t| 4 歌曲查找 |" << endl; cout << "\t\t\t|------------------------------------------|" << endl; cout << "\t\t\t| 5 歌曲浏览 |" << endl; cout << "\t\t\t|------------------------------------------|" << endl; cout << "\t\t\t| 6 个人收藏夹 |" << endl; cout << "\t\t\t|------------------------------------------|" << endl; cout << "\t\t\t| 7 歌曲分组显示 |" << endl; cout << "\t\t\t|------------------------------------------|" << endl; cout << "\t\t\t| 8 清空系统数据 |" << endl; cout << "\t\t\t|------------------------------------------|" << endl; cout << "\t\t\t| 0 退出 |" << endl; cout << "\t\t\t|------------------------------------------|" << endl; cout << "\t\t\t请选择【0-8】:"; cin >> sel; while(sel != "0" && sel != "1" && sel != "2" && sel != "3" && sel != "4" && sel != "5" && sel != "6" && sel != "7" && sel != "8") { cout << "\t\t\t输入不合法,请重新选择【0-8】:"; cin >> sel; } if(sel == "1") { this->insertList(); this->menu(); } else if(sel == "2") { this->deleteList(); this->menu(); } else if(sel == "3") { this->updateList(); this->menu(); } else if(sel == "4") { this->selectList(); this->menu(); } else if(sel == "5") { this->displayList(); this->menu(); } else if(sel == "6") { this->favorites(); this->menu(); } else if(sel == "7") { this->groupList(); this->menu(); } else if(sel == "8") { this->clearList(); this->menu(); } else if(sel == "0") { exit(0); } }
void SongSystem::readFile() { ifstream ifs; ifs.open("songs.txt", ios::in); int n = 0; ifs >> n; for(int i = 0; i < n; i++) { Song s; ifs >> s.name >> s.singer >> s.author >> s.composer >> s.album >> s.length >> s.language >> s.date >> s.hot; songs.push_back(s); } int m = 0; ifs >> m; for(int i = 0; i < m; i++) { Song s; ifs >> s.name >> s.singer >> s.author >> s.composer >> s.album >> s.length >> s.language >> s.date >> s.hot; mySongs.push_back(s); } ifs.close(); }
void SongSystem::writeFile() { ofstream ofs; ofs.open("songs.txt", ios::out); ofs << songs.size() << endl; for (int i = 0; i < songs.size(); i++) { ofs << songs[i].name << " " << songs[i].singer << " " << songs[i].author << " " << songs[i].composer<< " " << songs[i].album << " " << songs[i].length << " " << songs[i].language << " " << songs[i].date << " " << songs[i].hot << endl; } ofs << mySongs.size() << endl; for (int i = 0; i < mySongs.size(); i++) { ofs << mySongs[i].name << " " << mySongs[i].singer << " " << mySongs[i].author << " " << mySongs[i].composer<< " " << mySongs[i].album << " " << mySongs[i].length << " " << mySongs[i].language << " " << mySongs[i].date << " " << mySongs[i].hot << endl; } ofs.close(); }
void SongSystem::insertList() { while(true) { system("cls"); cout << "\t**************************************欢迎来到歌曲添加功能****************************************" << endl; cout << "\t乐库【" << songs.size() << "首】:" << endl; displaySong(this->songs); cout << endl; cout << "\t------------------" << endl; cout << "\t1 添加歌曲信息" << endl; cout << "\t2 返回主菜单" << endl; cout << "\t------------------" << endl; cout << "\t请选择【1-2】:"; string sel; cin >> sel; while(sel != "1" && sel != "2") { cout << "\t输入不合法,请重新输入【1-2】:"; cin >> sel; } if(sel == "1") { string flag = "1"; while (flag == "1") { Song s; bool check = false; do { check = false; cout << "\t输入歌曲信息:"<<endl; cout << "\t歌曲名:"; cin >> s.name; cout << "\t演唱者:"; cin >> s.singer; for(int i = 0; i < songs.size(); ++i) { if(s.name == songs[i].name && s.singer == songs[i].singer) { cout<<"\t该首歌曲信息已存在,请勿重复添加!" << endl; check = true; break; } } } while(check); cout << "\t作词:"; cin >> s.author; cout << "\t作曲:"; cin >> s.composer; cout<<"\t所属专辑:"; cin >> s.album; cout<<"\t歌曲时长:"; cin >> s.length; cout<<"\t语言:"; cin >> s.language; cout<<"\t发行日期(yyyy-mm-dd格式输入):"; cin >> s.date; s.hot = 0; songs.push_back(s); writeFile(); cout << "\n\t该首歌曲信息添加成功!是否继续添加?(1 是 0 否)" << endl; cout << "\t请进行选择【0-1】:"; cin >> flag; while(flag != "0" && flag != "1") { cout << "\t输入不合法,请重新选择【0-1】:"; cin >> flag; } } cout << "\t"; system("pause"); } else { break; } } }
void SongSystem::deleteList() { while (true) { system("cls"); cout << "\t**************************************欢迎来到歌曲删除功能****************************************" << endl; cout << "\t乐库【" << songs.size() << "首】:" << endl; displaySong(this->songs); cout << endl; string sel = "0"; cout << "\t----------------------" << endl; cout << "\t1 按歌曲名、演唱者删除" << endl; cout << "\t2 返回主菜单" << endl; cout << "\t----------------------" << endl; cout << "\t请进行选择【1-2】:"; cin >> sel; while(sel != "1" && sel != "2") { cout << "\t输入不合法,请重新选择【1-2】:"; cin >> sel; } if (sel == "1") { string keyName, keySinger; bool flag = false; cout << "\t请输入待删除歌曲的歌曲名:"; cin >> keyName; cout << "\t请输入待删除歌曲的演唱者:"; cin >> keySinger; for (vector<Song>::iterator it = songs.begin(); it != songs.end(); ++it) { if (it->name == keyName && it->singer == keySinger) { flag = true; cout << "\t待删除歌曲的信息如下:" << endl; cout << "\t--------------------------------------------------------------------------------------------------" << endl; cout<<"\t"; Song::showHeader(); cout << "\t--------------------------------------------------------------------------------------------------" << endl; cout<<"\t"; it->showSongInfo(); cout << "\t--------------------------------------------------------------------------------------------------" << endl; cout << "\t确认删除?(1 是 0 否)" << endl; cout << "\t请进行选择【0-1】:"; string ch = "0"; cin >> ch; while(ch != "0" && ch != "1") { cout << "\t输入不合法,请重新选择【0-1】:"; cin >> ch; } if (ch == "0") break; else { songs.erase(it); writeFile(); cout << "\t删除成功!" << endl; break; } } } if (!flag) cout << "\t系统中无法查询到此首歌曲,无法删除!\n" << endl; cout << "\t"; system("pause"); } else { break; } } }
void SongSystem::updateList() { while(true) { system("cls"); cout << "\t**************************************欢迎来到歌曲修改功能****************************************" << endl; cout << "\t乐库【" << songs.size() << "首】:" << endl; displaySong(this->songs); cout << endl; string sel = "0"; cout << "\t-----------------" << endl; cout << "\t1 修改歌曲信息" << endl; cout << "\t2 返回主菜单" << endl; cout << "\t-----------------" << endl; cout << "\t请进行选择【1-2】:"; cin >> sel; while(sel != "1" && sel != "2") { cout << "\t输入不合法,请重新选择【1-2】:"; cin >> sel; } if(sel == "1") { bool flag = false; string keyName, keySinger; cout << "\t请输入待修改歌曲的歌曲名:"; cin >> keyName; cout << "\t请输入待修改歌曲的演唱者:"; cin >> keySinger; for (int i = 0; i < songs.size(); i++) { if (songs[i].name == keyName && songs[i].singer == keySinger) { flag = true; cout << "\t待修改歌曲的基本信息如下:" << endl; cout << "\t--------------------------------------------------------------------------------------------------" << endl; cout <<"\t"; Song::showHeader(); cout << "\t--------------------------------------------------------------------------------------------------" << endl; cout << "\t"; songs[i].showSongInfo(); cout << "\t--------------------------------------------------------------------------------------------------" << endl; Song s = songs[i]; bool check = false; do { check = false; cout << "\t输入修改后的歌曲信息:"<< endl; cout << "\t歌曲名:"; cin >> s.name; cout << "\t演唱者:"; cin >> s.singer; for(int j = 0; j < songs.size(); ++j) { if(s.name == songs[j].name && s.singer == songs[j].singer && i != j) { cout<<"\t无法修改为已经添加进系统中的歌曲!" << endl; check = true; break; } } } while(check); cout << "\t作词:"; cin >> s.author; cout << "\t作曲:"; cin >> s.composer; cout << "\t所属专辑:"; cin >> s.album; cout << "\t歌曲时长:"; cin >> s.length; cout << "\t语言:"; cin >> s.language; cout <<"\t发行日期(yyyy-mm-dd格式输入):"; cin >> s.date; cout << "\t是否确认修改?(1 是 0 否)" << endl; cout << "\t请进行选择【0-1】:"; string ch = "0"; cin >> ch; while(ch != "0" && ch != "1") { cout << "\t\t输入不合法,请重新选择【0-1】:"; cin >> ch; } if (ch == "0") break; else { songs[i] = s; cout << "\t修改成功!" << endl; writeFile(); break; } } } if (!flag) cout << "\t系统中无法查询到此首歌曲,无法修改!\n" << endl; cout << "\t"; system("pause"); } else { break; } } }
void SongSystem::selectList() { while (true) { system("cls"); cout << "\t***************************************欢迎来到歌曲查找功能***************************************" << endl; cout << "\t-----------------" << endl; cout << "\t1 按歌曲名查找" << endl; cout << "\t2 按演唱者查找" << endl; cout << "\t3 返回主菜单" << endl; cout << "\t-----------------" << endl; cout << "\t请进行选择【1-3】:"; string sel = "0"; cin >> sel; while(sel != "1" && sel != "2" && sel != "3") { cout << "\t输入不合法,请重新选择【1-3】:"; cin >> sel; } if (sel == "1") { string keyName; bool flag = false; cout << "\t请输入待查询歌曲的歌曲名:"; cin >> keyName; cout << "\t查询结果如下:" << endl; cout << "\t--------------------------------------------------------------------------------------------------" << endl; cout << "\t"; Song::showHeader(); cout << "\t--------------------------------------------------------------------------------------------------" << endl; for (int i = 0; i < songs.size(); i++) { if(songs[i].name.find(keyName) != string::npos) { flag = true; cout << "\t"; songs[i].hot += 1; for(int j = 0; j < mySongs.size(); ++j) { if(songs[i].name == mySongs[j].name && songs[i].singer == mySongs[j].singer) { mySongs[j] = songs[i]; } } songs[i].showSongInfo(); } } cout << "\t--------------------------------------------------------------------------------------------------" << endl; writeFile(); if (!flag) cout << "\t系统中无法查询到此首歌曲!\n" << endl; cout << "\t"; system("pause"); } else if (sel == "2") { string keySinger; bool flag = false; cout << "\t请输入待查询歌曲的演唱者:"; cin >> keySinger; cout << "\t查询结果如下:" << endl; cout << "\t--------------------------------------------------------------------------------------------------" << endl; cout << "\t"; Song::showHeader(); cout << "\t--------------------------------------------------------------------------------------------------" << endl; for (int i = 0; i < songs.size(); i++) { if(songs[i].singer.find(keySinger) != string::npos) { flag = true; cout<<"\t"; songs[i].hot += 1; songs[i].showSongInfo(); } } cout << "\t--------------------------------------------------------------------------------------------------" << endl; writeFile(); if (!flag) cout << "\t系统中无法查询到该歌手的歌曲!\n" << endl; cout << "\t"; system("pause"); } else { break; } } }
void SongSystem::displaySong(vector<Song>& ss) { cout << "\t--------------------------------------------------------------------------------------------------" << endl; cout << "\t"; Song::showHeader(); cout << "\t--------------------------------------------------------------------------------------------------" << endl; for (int i = 0; i < ss.size(); i++) { cout << "\t"; ss[i].showSongInfo(); } cout << "\t--------------------------------------------------------------------------------------------------" << endl; }
void SongSystem::displaySong(vector<Song>& ss, int n) { int num = n < ss.size() ? n : ss.size(); cout << "\t--------------------------------------------------------------------------------------------------" << endl; cout << "\t"; Song::showHeader(); cout << "\t--------------------------------------------------------------------------------------------------" << endl; for (int i = 0; i < num; i++) { cout << "\t"; ss[i].showSongInfo(); } cout << "\t--------------------------------------------------------------------------------------------------" << endl; }
static bool cmp1(const Song& s1,const Song& s2) { return s1.singer < s2.singer; }
static bool cmp2(const Song& s1,const Song& s2) { return s1.hot > s2.hot; }
void SongSystem::displayList() { while(true) { system("cls"); cout << "\t***************************************欢迎来到歌曲浏览功能***************************************" << endl; string sel = "0"; cout << "\t----------------------" << endl; cout << "\t1 浏览乐库" << endl; cout << "\t2 浏览热歌榜" << endl; cout << "\t3 返回主菜单" << endl; cout << "\t----------------------" << endl; cout << "\t请进行选择【1-3】:"; cin >> sel; while(sel != "1" && sel != "2" && sel != "3") { cout << "\t输入不合法,请重新选择【1-3】:"; cin >> sel; } if (sel == "1") { cout << "\t乐库【" << songs.size() << "首】:" << endl; sort(songs.begin(), songs.end(), cmp1); this->displaySong(this->songs); cout << "\t"; system("pause"); } else if(sel == "2") { cout << "\n\t热歌榜:" << endl; sort(songs.begin(), songs.end(), cmp2); this->displaySong(this->songs, 10); cout << "\t"; system("pause"); } else { break; } } }
void SongSystem::favorites() { while(true) { system("cls"); cout << "\t***************************************欢迎来到个人收藏夹功能*************************************" << endl; cout << "\t我的收藏夹【目前" << mySongs.size() << "首歌曲】:" << endl; sort(mySongs.begin(), mySongs.end(), cmp1); this->displaySong(this->mySongs); string sel = "0"; cout << "\t----------------------" << endl; cout << "\t1 添加歌曲至个人收藏夹" << endl; cout << "\t2 从个人收藏夹删除歌曲" << endl; cout << "\t3 返回主菜单" << endl; cout << "\t----------------------" << endl; cout << "\t请进行选择【1-3】:"; cin >> sel; while(sel != "1" && sel != "2" && sel != "3") { cout << "\t输入不合法,请重新选择【1-3】:"; cin >> sel; } if (sel == "1") { string keyName; Song s; bool flag = false; cout << "\t请输入待添加歌曲的歌曲名:"; cin >> keyName; cout << "\t查询结果如下:" << endl; cout << "\t--------------------------------------------------------------------------------------------------" << endl; cout << "\t"; Song::showHeader(); cout << "\t--------------------------------------------------------------------------------------------------" << endl; for (int i = 0; i < songs.size(); i++) { if(songs[i].name.find(keyName) != string::npos) { flag = true; s = songs[i]; cout<<"\t"; songs[i].showSongInfo(); break; } } cout << "\t--------------------------------------------------------------------------------------------------" << endl; if (!flag) cout << "\t系统中无法查询到此首歌曲!\n" << endl; else { cout << "\t是否确认收藏?(1 是 0 否)" << endl; cout << "\t请进行选择【0-1】:"; string ch = "0"; cin >> ch; while(ch != "0" && ch != "1") { cout << "\t\t输入不合法,请重新选择【0-1】:"; cin >> ch; } if (ch == "0") break; else { mySongs.push_back(s); cout << "\t收藏成功!" << endl; writeFile(); }
} cout << "\t"; system("pause"); } else if(sel == "2") { string keyName, keySinger; bool flag = false; cout << "\t请输入待删除歌曲的歌曲名:"; cin >> keyName; cout << "\t请输入待删除歌曲的演唱者:"; cin >> keySinger; for (vector<Song>::iterator it = mySongs.begin(); it != mySongs.end(); ++it) { if (it->name == keyName && it->singer == keySinger) { flag = true; cout << "\t待删除歌曲的信息如下:" << endl; cout << "\t--------------------------------------------------------------------------------------------------" << endl; cout << "\t"; Song::showHeader(); cout << "\t--------------------------------------------------------------------------------------------------" << endl; cout << "\t"; it->showSongInfo(); cout << "\t--------------------------------------------------------------------------------------------------" << endl; cout << "\t确认删除?(1 是 0 否)" << endl; cout << "\t请进行选择【0-1】:"; string ch = "0"; cin >> ch; while(ch != "0" && ch != "1") { cout << "\t输入不合法,请重新选择【0-1】:"; cin >> ch; } if (ch == "0") break; else { mySongs.erase(it); writeFile(); cout << "\t删除成功!" << endl; break; } } } if (!flag) cout << "\t系统中无法查询到此首歌曲,无法删除!\n" << endl; cout << "\t"; system("pause"); } else { break; } } }
void SongSystem::groupList() { system("cls"); cout << "\t************************************欢迎来到歌曲分组显示功能**************************************" << endl; cout << "\t歌曲分组显示:"<< endl << endl; set<string> ss; for(int i = 0; i < songs.size(); ++i) { ss.insert(songs[i].singer); } int cnt = 0; for(set<string>::iterator it = ss.begin(); it != ss.end(); ++it) { cnt++; cout << "\t第" << cnt << "组--演唱者:" << (*it) << endl; cout << "\t--------------------------------------------------------------------------------------------------" << endl; cout << "\t"; Song::showHeader(); cout << "\t--------------------------------------------------------------------------------------------------" << endl; for (int j = 0; j < songs.size(); j++) { if(songs[j].singer == (*it)) { cout << "\t"; songs[j].showSongInfo(); } } cout << "\t--------------------------------------------------------------------------------------------------" << endl; cout << endl; } cout << "\t"; system("pause"); }
void SongSystem::clearList() { while (true) { string sel = "0"; system("cls"); cout << "\t*************************************欢迎来到清空系统数据功能*************************************" << endl; cout << "\t------------------" << endl; cout << "\t1 确认清空系统数据" << endl; cout << "\t2 返回主菜单" << endl; cout << "\t------------------" << endl; cout << "\t请慎重选择【1-2】:"; cin >> sel; while(sel != "1" && sel != "2") { cout << "\t输入不合法,请重新输入【1-2】:"; cin >> sel; } if (sel == "1") { songs.clear(); mySongs.clear(); cout << "\t清空成功!" << endl; cout << "\t"; system("pause"); writeFile(); } else { break; } } }
int main() { SongSystem ssy; ssy.init(); ssy.menu(); return 0; }
|