1

(4 відповідей, залишених у C++)

Потрібно за першим стовпцем(Найменування товару) відсортувати її за алфавітом.

#include <iostream>
#include <string>
#include <Windows.h>
#include <iomanip>
#define SIZE 10

using namespace std;

struct Stationery {
    string name_type;
    char item_type;
    short int min_amount;
    double price;
}stationery[SIZE];

int main() {
    SetConsoleCP(1251);
    SetConsoleOutputCP(1251);

    int cntr, cout_cntr;

    cout << "Данні: " << endl;
    for (cntr = 0; cntr < SIZE; cntr++) {
        cout << cntr + 1 << ". Найменування товару: ";
        cin >> stationery[cntr].name_type;

        if (stationery[cntr].name_type == "Кінець") {
            break;
        }

        cout << "\t" << "Тип товарy: ";
        cin >> stationery[cntr].item_type;

       cout << "\t" << "Ціна за 1 шт.(грн.): ";
       cin >> stationery[cntr].price;

        cout << "\t" << "Мінімальна вартість товару: ";
        cin >> stationery[cntr].min_amount;
        cout << endl;
    }

    cout << endl << endl << endl << endl << endl;
    cout << "-------------------------------------------------------------------------------------------" << endl;
    cout << "|                                          Прайс-лист                                     |" << endl;
    cout << "-------------------------------------------------------------------------------------------" << endl;
    cout << "| Найменування товару | Тип товара | Ціна за 1 шт.(грн.) |   Мінімальна вартість товару   |" << endl;
    cout << "-------------------------------------------------------------------------------------------" << endl;
    for (cout_cntr = 0; cout_cntr < cntr; cout_cntr++) {
        cout << "|" << setw(14) << stationery[cout_cntr].name_type << setw(8) << "|" << setw(6) << stationery[cout_cntr].item_type << setw(7) << "|"
            << setw(13) << stationery[cout_cntr].price << setw(10) << "|" << setw(17) << stationery[cout_cntr].min_amount << setw(15) << "|"
            << endl;
        cout << "-------------------------------------------------------------------------------------------" << endl;
    }

    return 0;
}

Знаю алгоритми, але не знаю як відсортувати за структурою. Як змінити:

    for (int i = 0; i < cntr; i++) {
        for (int j = 0; j < cntr; j++) {
            int a = stationery.name_type;
            int b = cntr[j + 1];
            if (a > b) {
                string buf = cntr[j];
                cntr[j] = cntr[j + 1];
                cntr[j + 1] = buf;
            }
        }
        cout << str << endl;
    }

Не виводить всю введенну інформацію в таблицю, а тількі останні введені данні.

#include <iostream>
#include <string>
#include <Windows.h>
#include <iomanip>

using namespace std;

struct Stationery {
    string name_type;
    char item_type;
    short int min_amount;
    double price;
}stationery;

int main() {
    SetConsoleCP(1251);
    SetConsoleOutputCP(1251);

    int cntr;

    cout << "Данні: " << endl;
    for (cntr = 0; cntr < 9; cntr++) {
        cout << cntr + 1 << ". Найменування товару: ";
        cin >> stationery.name_type;

        if (stationery.name_type == "Кінець") {
            break;
        }

        cout << "\t" << "Тип товару: ";
        cin >> stationery.item_type;

        cout << "\t" << "Ціна за 1 шт.(грн.): ";
        cin >> stationery.price;

        cout << "\t" << "Мінімальна кількість у партії: ";
        cin >> stationery.min_amount;

        cout << endl;
    }

    cout << endl << endl << endl << endl << endl;
    cout << "-------------------------------------------------------------------------------------------" << endl;
    cout << "|                                          Прайс-лист                                     |" << endl;
    cout << "-------------------------------------------------------------------------------------------" << endl;
    cout << "| Найменування товару | Тип товару | Цiна за 1 шт. (грн.) | Мiнiмальна кiлькiсть у партiї |" << endl;
    cout << "-------------------------------------------------------------------------------------------" << endl;
    for (int cout_cntr = 0; cout_cntr < cntr; cout_cntr++) {
        cout << "|" << setw(14) << stationery.name_type << setw(8) << "|" << setw(6) << stationery.item_type << setw(7) << "|"
            << setw(13) << stationery.price << setw(10) << "|" << setw(17) << stationery.min_amount << setw(15) << "|"
            << endl;
        cout << "-------------------------------------------------------------------------------------------" << endl;
    }
    return 0;
}

3

(9 відповідей, залишених у C++)

Ну потрібно зробити ось таке завдання.

Але в мене навіть не виводить числа0)

4

(9 відповідей, залишених у C++)

#include <iostream>
#include <iomanip>
#define SIZE 10

using namespace std;

void printArray(int array[SIZE][SIZE]);

int main() {
    int array[SIZE][SIZE];
    printArray(array);

    return 0;
}

void printArray(int array[SIZE][SIZE]) {
    for (int j = 0; j < SIZE; j++) {
        for (int k = 0; k < SIZE; k++) {
            cout << setw(5) << array[j][k];
        }
        cout << endl;
    }
}

Виводить кожні значення масиву як -87867596. Як зробити щоб було від 1 до 10? Начеб-то все правильно

#

include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main() {
    setlocale(LC_ALL, "Russian");

    string  folder,
            papyrus,
            calculator,

            stationery,
            office_equipment;

    unsigned short int  min_amount_folder,
                        min_amount_papyrus,
                        min_amount_calculator;

    double price_for_one_FOLDER,
           price_for_one_PAPYRUS,
           price_for_one_CALCULATOR;


     cout << "1 - Введiть найменування товару, тип товару, цiну за 1шт.(грн.), мiнiмальну кiлькiсть у партiї: " << endl;
     cin >> folder;
     cin >> stationery;
     cin >> price_for_one_FOLDER;
     cin >> min_amount_folder;

     cout << "2 - Введiть найменування товару, тип товару, цiну за 1шт.(грн.), мiнiмальну кiлькiсть у партiї: " << endl;
     cin >> papyrus;
     cin >> stationery;
     cin >> price_for_one_PAPYRUS;
     cin >> min_amount_papyrus;

     cout << "3 - Введiть найменування товару, тип товару, цiну за 1шт.(грн.), мiнiмальну кiлькiсть у партiї: " << endl;
     cin >> calculator;
     cin >> office_equipment;
     cin >> price_for_one_CALCULATOR;
     cin >> min_amount_calculator;
    
    cout << "-------------------------------------------------------------------------------------------" << endl;
    cout << "|                                          Прайс-лист                                     |" << endl;
    cout << "-------------------------------------------------------------------------------------------" << endl;
    cout << "| Найменування товару | Тип товару | Цiна за 1 шт. (грн.) | Мiнiмальна кiлькiсть у партiї |" << endl;
    cout << "-------------------------------------------------------------------------------------------" << endl;
    cout << "|" << setw(14) << folder << setw(8) << "|" << setw(6) << stationery << setw(7) << "|"
                << setw(13) << price_for_one_FOLDER << setw(10) << "|" << setw(17) << min_amount_folder << setw(15) << "|"
                << endl;
    cout << "-------------------------------------------------------------------------------------------" << endl;
    cout << "|" << setw(14) << papyrus << setw(8) << "|" << setw(6) << stationery << setw(7) << "|"
                << setw(13) << price_for_one_PAPYRUS << setw(10) << "|" << setw(17) << min_amount_papyrus << setw(15) << "|"
                << endl;
    cout << "-------------------------------------------------------------------------------------------" << endl;
    cout << "|" << setw(17) << calculator << setw(5) << "|" << setw(6) << office_equipment << setw(7) << "|"
                << setw(13) << price_for_one_CALCULATOR << setw(10) << "|" << setw(17) << min_amount_calculator << setw(15) << "|"
                << endl;
    cout << "-------------------------------------------------------------------------------------------" << endl;
    cout << "|Примiтка: К - канцтовари, О - оргтехнiка                                                 |" << endl;
    cout << "-------------------------------------------------------------------------------------------" << endl;

    return 0;
}

6

(6 відповідей, залишених у C++)

Виникло велике бажання програмувати. Ось почав самостійно освоювати С, хоча в універе була...

Є таке завдання:
1. Написати прямокутний трикутник, ось такого вигляду:
  *
  **
  ***
  ****
  *****
2. Написати прямокутний трикутник, ось такого вигляду:
       *
      **
    ***
  ****
*****


P.S Що треба зробити щоб виник малюнок хоча б на 1 картинці, а то кожного разу як я перероблю код виникае квадрат...

#include <stdio.h>

main(){
    int number; 
    
    printf("Enter the value: ");
    scanf("%d", &number);
    
    int i, j, k;
    
    for(i=0; i<number; i++){
        for(j=0; j<number; j++){
            printf("*");
        }
        printf("\n");
    }
}

Дякую!

7

(5 відповідей, залишених у C++)

0x9111A написав:

Я так розумію, що навчаєтесь не на філології?

Навчаюсь на спортивному, а програмування як логіка для мізків

8

(5 відповідей, залишених у C++)

blizzard написав:

Напишіть рекурсивну функцію recursiveMinimum, яка приймає масив і розмір масиву як аргументи, і повертає найменший елемент масиву. Функція повинна зупиняти свою роботу і повертатись, якщо приймаємий масив має один елемент.

Навчаюсь не на программіста, повинен доздати лабороторну за прошлий семестр, а то можуть вигнати =)
Заздалегідь дякую!

Напишіть рекурсивну функцію recursiveMinimum, яка приймає масив і розмір масиву як аргументи, і повертає найменший елемент масиву. Функція повинна зупиняти свою роботу і повертатись, якщо приймаємий масив має один елемент.

10

(4 відповідей, залишених у Пропоную роботу)

koala написав:

Ціна питання?

Можу надіслати 60руб(російських) =)*

11

(4 відповідей, залишених у Пропоную роботу)

Допоможіть будь ласочка с цим завдання. В програмуванні нічого не шарю, навіть не проф спрямування. На завтра треба зробити, дякую!!!!