Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <string>
- #include <Windows.h>
- #include <fstream>
- #include <cstdio>
- using namespace std;
- struct List {
- string name;
- char rayon1[20];
- char rayon2[20];
- char rayon3[20];
- List *nxt;
- };
- void vvod(List* head, int n, int size) {
- List* tmp = head;
- ifstream fin("ss.txt");
- for (int i = 0; i < n; ++i) {
- if (i) {
- tmp->nxt = new List;
- tmp = tmp->nxt;
- size++;
- }
- fin >> tmp->name;
- fin >> tmp->rayon1;
- fin >> tmp->rayon2;
- fin >> tmp->rayon3;
- tmp->nxt = NULL;
- }
- fin.close();
- }/*
- void remove_element(List *head, int n, int size)
- {
- List* tmp = head;
- int i = 0;
- List* prev = NULL;
- if (head!=NULL && n < size)
- {
- while(tmp && i < n-1) {
- ++i;
- prev = tmp;
- tmp = tmp->nxt;
- }
- if (!tmp) {
- return;
- }
- if (head == tmp)
- {
- head = tmp->nxt;
- }
- else
- {
- if (prev) {
- prev->nxt = tmp->nxt;
- }
- }
- size--;
- delete(tmp);
- }
- }*/
- void vivod(List *head, int n) {
- List* tmp = head;
- for (int i = 0; i < n; ++i) {
- cout << " NOMER " << i + 1 << endl;
- cout << tmp->name;
- cout << endl;
- cout << tmp->rayon1 << " " << tmp->rayon2 << " " << tmp->rayon3 << endl;
- tmp = tmp->nxt;
- }
- }
- void redaktirovat(int zbPos, List *head, string name, char rayon1[20], char rayon2[20], char rayon3[20], char s[20], char s1[20], char s2[20], string gorod)
- {
- for (int i = 0; i < zbPos; ++i)
- head = head->nxt;
- head->name = gorod;
- strcpy(head->rayon1, s);
- strcpy(head->rayon2, s1);
- strcpy(head->rayon3, s2);
- }
- int main()
- {
- List *head = new List;
- int n=0;
- int zbPos;
- string gorod;
- char stroka[20];
- char stroka1[20];
- char stroka2[20];
- int z = 0;
- cout << " Vvedite kolichestvo gorodov " << endl;
- cin >> n;
- int size = n;
- vvod(head, n, size);
- //cout << "size:" << size << endl;
- vivod(head, n);
- cout << " Cho pomenyat? " << endl;
- cin >> zbPos;
- cin.ignore();
- cout << " Gorod -> " << endl;
- cin >> gorod;
- cin.ignore();
- cout << " Rayon1-> " << endl;
- cin.getline(stroka, 20, '\n');
- cin.ignore();
- cout << " Rayon2-> " << endl;
- cin.getline(stroka1, 20, '\n');
- cin.ignore();
- cout << " Rayon3-> " << endl;
- cin.getline(stroka2, 20, '\n');
- redaktirovat(zbPos, head, head->name, head->rayon1, head->rayon2, head->rayon3, stroka, stroka1, stroka2, gorod);
- //cout << "Cho udalit? " << endl;
- //cin >> z;
- //remove_element(head, z, size);
- vivod(head, n);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement