Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <Windows.h>
- #include <string.h>
- #define N 25
- using namespace std;
- struct book
- {
- char lastname[20];
- char firstname[20];
- char book[20];
- }x;
- void output(struct book x[])
- {
- cout << "\n\n\nФамилия Имя :\t \n"<<x->lastname<<" ";
- cout<<x->firstname<<"\n";
- cout << "название книги:\t\n"<<x->book;
- }
- void input(struct book *x)
- {
- cin >> x->lastname >> x->firstname >> x->book;
- }
- int main ()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- int n;
- int i;
- cin >> n;
- struct book x[N];
- cout<<"Введите фамилию, имя автора и название книги: \n";
- for (i=0;i<n;i++)
- {
- input(&x[i]);
- }
- int k=1;
- char key;
- do
- {
- printf("Хотите добавить запись?(y/n) :\n");
- scanf("%s", &key);
- //if (scanf("%s", &key) == 1)
- // key = -1;
- switch (key)
- {
- case 'y':
- if (n < N)
- {
- n++;
- for (i=n; i > 0; i--)
- {
- x[i] = x[i-1];
- } // îñâîáîäèòü ýëåìåíò a[0]
- printf("Введите данные :\n");
- input(&x[0]);
- cout<<n;
- }
- else
- printf("\aOut of memory!\n");
- break;
- case 'n':
- cout<<n;
- k=0;
- break;
- default:
- printf("\aWrong operation number!\n");
- break;
- break;
- }} while (k);
- cout<<n;
- for (i=0;i<n;i++)
- {
- output(&x[i]);
- }
- return(0);
- system ("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement