#include <stdio.h>
#include <stdlib.h>
#include<locale.h>
#include <Windows.h>
#include<string.h>
typedef struct {
char name[10] ;
struct
{
int girth, rost;
}razm;
char country[20];
}struc;
typedef struct Node {
struc A;
struct Node* next;
}Node;
Node* cip(struc x);
void back(Node** p, struc x);
void prin(Node* p);
void main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
int A = 1, i=1;
Node* p = 0;
struc x,y;
Node* head=0;
while (A != 0)
{
printf("Одежда №%d\n", i);
printf("Введите название %d-го вида одежды: ", i);
scanf("%s", &x.name);
if (x.name[0] == '*') break;
printf("Введите рост для %d-го вида одежды: ", i);
scanf("%d", &x.razm.rost);
printf("Введите обхват для %d-го вида одежды: ", i);
scanf("%d", &x.razm.girth);
printf("Введите страну изготовителя %d-го вида одежды: ", i);
scanf("%s", &x.country);
printf("\n");
if (A == 1)
{
p = cip(x);
head = p;
A += 1;
}
else back(&p,x);
i++;
}
prin(p);
y = p->A;
while (p != NULL) {
if (p->next == NULL) {
x = p->A;
p->A = y;
}
p = p->next;
}
p = head;
p->A = x;
prin(p);
}
Node* cip(struc x) {
Node* t = (Node*)malloc(sizeof(Node));
t->A = x;
t->next = NULL;
return t;
}
void back(Node** p, struc x) {
Node* NEWe = cip(x);
Node* tpm = *p;
while (tpm->next != NULL) {
tpm = tpm->next;
}
tpm->next = NEWe;
}
void prin(Node* p) {
int i=1;
printf ("\n+---+---------------+--------------------+----------------+\n"
"| | | размер | |\n"
"| № | Название |----------+---------| страна |\n"
"| | | рост | обхват | |\n"
"+---+---------------+----------+---------+----------------+\n");
while (p != NULL) {
printf ("| %-2d| %-14s| %-9d| %-8d| %-15s|\n",i,p->A.name, p->A.razm.rost, p->A.razm.girth, p->A.country);
printf ("+---------------------------------------------------------+\n");
p = p->next;
i++;
}
getch();
}```