Премини към съдържанието
Форумът в приложение

По-лесно сърфиране. Научи повече.

Kaldata.com - Форуми

Приложение на форума на цял екран с push известия, значки и други.

За да инсталирате това приложение на iOS и iPadOS
  1. Докоснете Иконата за споделяне в Safari
  2. Превъртете менюто и докоснете Добавяне към началния екран.
  3. Докоснете Добавяне в горния десен ъгъл.
За да инсталирате това приложение на Android
  1. Докоснете менюто с 3 точки (⋮) в горния десен ъгъл на браузъра.
  2. Докоснете Добавяне към началния екран или Инсталиране на приложение.
  3. Потвърдете, като докоснете Инсталиране.

Добре дошли!

Добре дошли в нашите форуми, пълни с полезна информация. Имате проблем с компютъра или телефона си? Публикувайте нова тема и ще намерите решение на всичките си проблеми. Общувайте свободно и открийте безброй нови приятели.

Моля, регистрирайте се за да публикувате тема и да получите пълен достъп до всички функции.

 

Вие как бихте го направили?

Featured Replies

Да се състави програма за нуждите на производствена организация, която съхранява в масив следните данни за работниците:

-         Име;

-          ЕГН;

-         Размер на дневно заплащане;

-         Брой на отброени дни през месеца и извършва следните операции,избрани от менюто:

-    Добавя към масив данните на нов работник;

-         Извежда имената и възрастта на от всички мъже;

-         Създава нов масив с имената и месечното заплащане на мъжете.

Не знам как да си направя Case '4':

И исках да попитам има ли как да си направя със Case'4': нов клас със Men и в него да имам циъкл и ако да как да го направя

Някой ако може да помогне!

#include <iostream>
#include <string>
#include<cstring>
using namespace std;

class CDate {
public:
    int D, M, G;
    void ReadDat();
    void WriteDat();
};

void CDate::ReadDat() {
    cout << "Day: "; cin >> D;
    cout << "Month: "; cin >> M;
    cout << "Year: "; cin >> G;
}
void CDate::WriteDat() {
    cout << D << '.' << M << '.' << G << endl;
}
class Workers {
public:
    string Name;
    string EGN;
    float money;
    int DayMouth;
    void getdata();
    void display();
    int getGender();
    CDate getRoDat();
    int getAge(CDate);
    void NewArryMen();
};
void Workers::getdata() {
    cin.ignore();
    cout << "Enter name: "; getline(cin, Name);
    cout << "Enter EGN: "; cin >> EGN;
    cout << "Enter a day wage money:"; cin >> money;
    cout << "Enter the number of days worked in the month "; cin >> DayMouth;
}
void Workers::display() {
    cout << "Name: " << Name << "\nEGN: " << EGN << "\nDay wage noney:" << money <<
        "\nNumber of days worked in the month: " << DayMouth << "\n";
}
int Workers::getGender() {
    char B[2];
    strncpy(B, EGN.c_str() + 8, 1); 
    B[1] = '\0';
    return stoi(B) % 2;
}
CDate Workers::getRoDat() {
    char b[3];
    CDate RoDat{};
    strncpy(b, EGN.c_str(), 2);   b[2] = '\0'; RoDat.G = stoi(b) + 1900;
    strncpy(b, EGN.c_str() + 2, 2); b[2] = '\0'; RoDat.M = stoi(b);
    strncpy(b, EGN.c_str() + 4, 2); b[2] = '\0'; RoDat.D = stoi(b);
    return RoDat;
}
int Workers::getAge(CDate CurrentDate) {
    CDate RoDat = getRoDat();
    int Age = CurrentDate.G - RoDat.G;
    cout<<"Enter curent information:";CurrentDate.ReadDat();
    if (CurrentDate.M < RoDat.M || CurrentDate.M == RoDat.M && CurrentDate.D < RoDat.D)Age--;
    return Age;
}
//за извеждане имената и възрастта на всички мъже:
void output (Workers mas[],int br) 
{
    CDate CurrentDate;
    for (int i = 0; i < br; i++)
        if (mas[i].getGender() == 0) 
        {
            cout << "Name is: " << mas[i].Name << endl;
            cout << "Age is: " << mas[i].getAge(CurrentDate) << endl;
        }
}
void NewArryMen(Workers* mas, int br) {
    Workers* pMaleWorkers = new Workers[br];
    int NumOfMales = 0;
        for (int i = 0; i < br; i++) {
            if (mas[i].getGender() == 0) {
                pMaleWorkers[NumOfMales].Name = mas[i].Name;
                pMaleWorkers[NumOfMales].money = mas[i].money;
            }
        }
}
int main() {
    char KodOp;
    int i;
    int NumberOfPeople = 10;
    Workers grupa[10];
    do {
        cout << "MENU OF PERFORMED OPERATIONS:\n";
        cout << "1- adds to the array the data of a new worker\n";
        cout << "2- displays all entered data\n";
        cout << "3- displays the names and ages of all men\n";
        cout << "4-creates a new array with the names and monthly salary of the men\n";
        cout << "Specify an operation or 0 to end:\n"; cin >> KodOp;
        switch (KodOp) {
        case'0':break;
        case'1':grupa[NumberOfPeople++].getdata(); break;
        case'2':for (i = 0; i < NumberOfPeople; i++)grupa[i].display(); break;
        case'3':output(grupa, NumberOfPeople); break;
        case'4':grupa[NumberOfPeople++].Name;
        grupa[NumberOfPeople++].money;
        case'5':default: cout << "WRONG OPERATION CODE!!!\n";


}
}while(KodOp!='0');
}

Разрешен от Raze

  • Решение

Пиши на chatGPT ще ти направи каквото ти трябва. Ако нещо не ти хареса, казваш му да го оправи.

Ами то така се прави по принцип... виж бота какво пише за choice 3.

#include <iostream>
#include <string>
#include <vector>
using namespace std;

struct Employee {
  string name;
  string number;
  double payment;
  int days_worked;
  char gender;
  int age;
};

struct MenSalary {
  string name;
  double salary;
};

int main() {
  const int MAX_EMPLOYEES = 10;
  Employee employees[MAX_EMPLOYEES];
  int num_employees = 0;

  while (true) {
    // Show menu
    cout << "Select an option:" << endl;
    cout << "1. Add a new employee to the array" << endl;
    cout << "2. Select all men with their name and age" << endl;
    cout << "3. Create a new array of men, with their name and monthly salary" << endl;
    cout << "4. Exit" << endl;

    int choice;
    cin >> choice;

    if (choice == 1) {
      if (num_employees < MAX_EMPLOYEES) {
        // Add a new employee
        cout << "Enter name for employee " << num_employees + 1 << ": ";
        cin.ignore();
        getline(cin, employees[num_employees].name);

        cout << "Enter 10-digit number for employee " << num_employees + 1 << ": ";
        getline(cin, employees[num_employees].number);

        cout << "Enter daily payment for employee " << num_employees + 1 << ": ";
        cin >> employees[num_employees].payment;

        cout << "Enter number of days worked for employee " << num_employees + 1 << " this month: ";
        cin >> employees[num_employees].days_worked;

        cout << "Enter gender for employee " << num_employees + 1 << " (M/F): ";
        cin >> employees[num_employees].gender;

        cout << "Enter age for employee " << num_employees + 1 << ": ";
        cin >> employees[num_employees].age;

        num_employees++;
        cout << "Employee added." << endl;
      } else {
        cout << "Array is full. Cannot add more employees." << endl;
      }
    } else if (choice == 2) {
      // Select all men with their name and age
      for (int i = 0; i < num_employees; i++) {
        if (employees[i].gender == 'M') {
          cout << "Name: " << employees[i].name << endl;
          cout << "Age: " << employees[i].age << endl;
          cout << endl;
        }
      }
    } else if (choice == 3) {
      // Create a new array of men, with their name and monthly salary
      vector<MenSalary> men;

      for (int i = 0; i < num_employees; i++) {
        if (employees[i].gender == 'M') {
          MenSalary m;
          m.name = employees[i].name;
          m.salary = employees[i].payment * employees[i].days_worked;
          men.push_back(m);
        }
      }

      cout << "Men's names and monthly salaries:" << endl;
      for (int i = 0; i < men.size(); i++) {
        cout << men[i].name << ": $" << men[i].salary << endl;
      }
    } else if (choice == 4) {
      // Exit the program
      break;
    } else {
      cout << "Invalid choice. Please try again." << endl;
    }
  }

  return 0;
}

 

Регистрирайте се или влезете в профила си за да коментирате

Разглеждащи това в момента 0

  • Няма регистрирани потребители разглеждащи тази страница.

Дарение

  • Подкрепи съществуването на форума - направи дарение
    32%
    Дарени 315 € от нужните 1 000 €

Бюлетин

Получавайте известие, когато има важна промяна или новина свързана с форума.

Профил

Навигация

Търсене

Търсене

Конфигуриране на push известия в браузъра

Chrome (Android)
  1. Докоснете иконата на катинар до адресната лента.
  2. Докоснете Разрешения → Известия.
  3. Променете предпочитанията си.
Chrome (Desktop)
  1. Кликнете върху иконата на катинар в адресната лента.
  2. Изберете Настройки на сайта.
  3. Намерете Известия и коригирайте предпочитанията си.