alinasun230503
07.06.2020 00:34

Сделать таблицу из текста(word)


Сделать таблицу из текста(word)

Нажмите на рекламу ниже и сразу увидите ответ
Популярные вопросы:
Ответ:
100116
19.04.2022 04:50
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>

struct StudentData
{
    std::string name;
    std::string surname;
    int math;
    int phys;
    int comp_science;
};

bool
comp(const StudentData &a, const StudentData &b)
{
    int tmp1 = a.math + a.phys + a.comp_science;
    int tmp2 = b.math + b.phys + b.comp_science;
    return tmp1 > tmp2 ? true : false;
}

int
main(void)
{
    int n;
    std::cin >> n;
    std::vector< StudentData > data(n);
    for (int i = 0; i < n; i++) {
        std::cin >> data[i].name >> data[i].surname;
        std::cin >> data[i].math >> data[i].phys >> data[i].comp_science;
    }
    std::sort(data.begin(), data.end(), comp);
    for (int i = 0; i < n; i++) {
        std::cout << data[i].name << " " << data[i].surname << std::endl;
    }
    return 0;
}
0,0(0 оценок)
Ответ:
black93
26.11.2020 00:23
Блок-схема - в прилагаемом файле.
Программа:
#include <iostream>
#include <stdlib.h>
using namespace std;

int main() {
const int n = 20;
int a[n];
int k1=0;
int k2=0;
int k3=0;

srand(time(0));
for (int i = 0; i < n; i++) {
a[i]=rand() % 3 +1;
cout << a[i] << " ";
}
cout <<"\n";
for (int i = 0; i < n; i++){
 switch(a[i]){
case 1: 
k1++; break;
case 2: 
k2++; break;
case 3: 
k3++; break;
 }
}
   cout << "k1 = " << k1 << "  k2 =  " << k2 << "  k3 =  " << k3 <<"\n"; 
return 0;
}

Пример:
2 1 2 1 2 1 3 3 2 3 1 3 1 2 3 2 1 3 3 3
k1 = 6 k2 = 6 k3 = 8
0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота