nord vpnnord vpn
Ad

Untitled

mail@pastecode.io avatar
unknown
plain_text
18 days ago
1.3 kB
4
Indexable
Never
//ЮФУ, ИКТИБ,МОП ЭВМ
//Программирование и основы теории алгоритмов
//Лабораторная работа 4.1 - Подпрограммы, библиотечные функции
//КТбо1-6, Домбрина Алёна Игоревна
// Задача C
// 16.11.2023
#include <iostream>
#include<string>
using namespace std;

int distance(string, string);
int main() {
    string s;
    string s2;
    cin >> s;
    int n;
    cin >> n;
    int count = 0;
    int min = 100000000;
    int arrcount[100000];
    for (int i = 0; i < n; i++)
    {
        cin >> s2;
        if (distance(s,s2) < min) 
        {
            min = distance(s, s2);
        }
        arrcount[i] = distance(s, s2);
    }
    int count2 = 0;
    for (int i = 0; i <n; i++)
    {
        if (arrcount[i] == min) 
        {
            count2++;
        }
    }
    cout << count2 << endl;
    for (int i = 0; i < n; i++)
    {
        if (arrcount[i] == min)
        {
            cout << (i + 1) << ' ';
        }
    }

    
    return 0;
}
int distance(string str1, string str2) {
    int count = 0;
    for (int j = 0; j < str2.length(); j++)
    {
        if (str1[j] != str2[j])
        {
            count++;
        }
    }
    return count;

}
Leave a Comment


nord vpnnord vpn
Ad