Witam, próbuję zrobić jedno zadanie, ale sprawdzarka daje 2/6, próbowałem juz wszystkiego i nie wiem o co chodzi.
Zadanie: https://i.imgur.com/w5zyq0K.png
Próba pierwsza
#include <iostream>
using namespace std;
#include <string>
int main()
{
int n;
cin >> n;
string *input = new string[n * 2];
string temp;
string tab;
for (int i = 0; i < n * 2; i++)
{
cin >> tab;
if(tab.length() <= 50) {
input[i] = tab;
}
}
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < n - i; ++j)
{
if (input[j] > input[j + 1])
{
temp = input[j];
input[j] = input[j + 1];
input[j + 1] = temp;
}
}
}
int count = 0;
char min = '-';
for (int i = 0; i < n * 2; i++)
{
cout << input[i] << endl;
count++;
if (count % 2 == 0 && count != 0)
{
for (int i = 0; i < 20; i++)
{
cout << min;
}
cout << endl;
}
}
delete[] input;
return 0;
}
Próba druga też 2/6
#include <string.h>
#include <stdio.h>
int main()
{
int numPairs;
scanf("%i", &numPairs);
for (int i = 0; i < numPairs; ++i) {
char first[50] = {0};
char second[50] = {0};
scanf("%s", first);
scanf("%s", second);
if (strcmp(first, second) < 0) {
printf("%s\n%s\n--------------------\n", first, second);
} else {
printf("%s\n%s\n--------------------\n", second, first);
}
}
}