A
A
AlekseyPilatov2020-12-04 16:11:12
C++ / C#
AlekseyPilatov, 2020-12-04 16:11:12

How to display structure data in tabular form?

Help to display at the end a table with structure data.
How to do it?

Program code:

#include <iostream> 
#include <string> 
using namespace std;
struct  strc {
    string shopName;
    int productCode;
    int productQuantity;
    int productQuantityKG;
    int productPrice;
}  
mtovar[100];
int  main() {
    setlocale(LC_ALL, "Russian");
    int nst=0, nst2=0, i, j,a;
    cout << "Введите кол-во магазинов: ";
    cin >> nst2;
    cout << endl;
    for (j = 1; j <= nst2; j++){
        cout << "Введите название " << j << " магазина: ";
        cin >> mtovar[j].shopName;
        cout << "Количество товаров " << j << " магазина: ";
        cin >> mtovar[j].productQuantity;
        cout << endl;
        for (i = 0; i < mtovar[j].productQuantity; i++) {
            cout << "Введите код товара: ";
            cin >> mtovar[i].productCode;
            cout << "Введите количество товару (у кг): ";
            cin >> mtovar[i].productQuantityKG;
            cout << "Цена за килограм: ";
            cin >> mtovar[i].productPrice;
            cout << endl;
        }
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
User700, 2020-12-06
@User700

Most likely the data structure is not appropriate for the task

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question