برگزیده های پرشین تولز

اشاره به اطلاعات وارد شده توسط کاربر و چاپ مجدد آن اطلاعات در صورت درست بودن

u0.m1

کاربر تازه وارد
تاریخ عضویت
22 آپریل 2014
نوشته‌ها
11
لایک‌ها
1
سن
42
سلام ،
ورودی: کاربر میاد اطلاعات خواسته شده رو وارد میکنه ، و سپس باتوجه و انتخاب های موجود یکی از کلید های زیر را بزند
خروجی: تابع ریپورت و دو تا تابع سرچ با توجه به خواست کاربر
(این برنامه رو با آرایه نوشتم ، ولی خواستم یه بار با رشته (string) امتحان کنم ، که چون مثله اینکه خیلی ساده تر میشه)
ممنون میشم به من تو قسمت تابع void isbn_search() کمک کنید ، وقتی دستور if ، درست است ، برنامه فقط cout هارو برمیگردونه در صورتی که میخوام cout هارو به علاوه اطلاعات وارد شده قبلی برگرداند.

کد:
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
struct Library
{
    string Book_Name;
    string Author;
    string Translator;
    string ISBN;
    string Subject;
    struct Library *fl, *bl;
}*start, *cur, *p;

void insert()
{
    p = new struct Library;
    p->fl = NULL;
    p->bl = cur;
    cur->fl = p;
    cur = p;
    cout << "Enter the specified informations for Books" << endl;
    cout << endl;
    cout << "The Name of the Book" << endl;
    cin >> p->Book_Name;
    getline(cin, p->Book_Name);
    cout << "Author" << endl;
    cin >> p->Author;
    getline(cin, p->Author);
    cout << "The Name of the Translator" << endl;
    cin >> p->Translator;
    getline(cin, p->Translator);
    cout << "International Standard Book Number (ISBN)" << endl;
    cin >> p->ISBN;
    getline(cin, p->ISBN);
    cout << "Enter the Subject of the Book" << endl;
    cin >> p->Subject;
    getline(cin, p->Subject);
}

void report()
{
    cout << "The list of all Books in Library are as below" << endl;
    for (p = start->fl; p != NULL; p = p->fl)
    {
        cout << "Book Name " << p->Book_Name << endl;
        cout << "Author Name " << p->Author << endl;
        cout << "Translator Name " << p->Translator << endl;
        cout << "ISBN of the Book " << p->ISBN << endl;
        cout << "Book Subject " << p->Subject << endl;
    }
}

void isbn_search()
{
    string is;
    cout << "Enter the Book's ISBN" << endl;
    cin >> is;
    getline(cin, is);
    {
        if (p->ISBN == is)
        {
            cout << "Book Name " << p->Book_Name << endl;
            cout << "Author Name " << p->Author << endl;
            cout << "Translator Name " << p->Translator << endl;
            cout << "ISBN of the Book " << p->ISBN << endl;
            cout << "Book Subject " << p->Subject << endl;
        }
        else
        {
            cout << "ERROR 404 - NOT FOUND" << endl;
        }
    }
  
}

void subject_search()
{
    string title;
    cout << "Enter Book's Subject " << endl;
    cin >> title;
    for (p = start->fl; p != NULL; p = p->fl)
    {
        if (p->Subject == title)
        {
            cout << "Book Name " << p->Book_Name << endl;
            cout << "Author Name " << p->Author << endl;
            cout << "Translator Name " << p->Translator << endl;
            cout << "ISBN of the Book " << p->ISBN << endl;
            cout << "Book Subject " << p->Subject << endl;
        }
        else
        {
            cout << "ERROR 404 - NOT FOUND" << endl;
        }
    }
}
/*
void delete_number_2()
{
    struct Library *ap, *bp;
    string name;
    cout << "Enter Author's Name or the Translator's Name so that search begins and delete" << endl;
    cin >> name;
    for (p = start->fl; p != NULL; p->fl = p)
    {
        if ((p->Author == name) || (p->Translator == name))
        {
            ap = p->fl;
            bp = p->bl;
            bp->fl = ap;
            ap->bl = bp;
            p->fl = NULL;
            p->bl = NULL;
            cout << "Book Name " << p->Book_Name << endl;
            cout << "Author Name " << p->Author << endl;
            cout << "Translator Name " << p->Translator << endl;
            cout << "ISBN of the Book " << p->ISBN << endl;
            cout << "Book Subject " << p->Subject << endl;
            delete(p);
            p = p->fl;
        }
      
        else
        {
            cout << "ERROR 404 - NOT FOUND" << endl;
        }
    }
}
*/
void main()
{
    char ch;
    start = new struct Library;
    start->fl = NULL;
    start->bl = NULL;
    cur = start;
    do
    {
        cout << "Enter I/i for Insert" << endl;
        cout << "Enter R/r for Report" << endl;
        cout << "Enter S/s for Search by ISBN and delete the Specific Book " << endl;
        cout << "Enter N/n for search  " << endl;
        cout << "Enter X/x for Terminating the Program " << endl;
        cin >> ch;
        switch (ch)
        {
        case 'I':
        case 'i':
            insert();
            break;
        case'R':
        case'r':
            report();
        case 'S':
        case 's':
            subject_search();
            break;
        case 'N':
        case 'n':
            isbn_search();
            break;
        }
    } while (ch != 'X' && ch != 'x');
}
 
بالا