Home
/
Aktualności
/
Artykuł
/

Zadanie 1

Wektory dodaj includy

using namespace std;

vector roznicaWektorow(vector wektor1, vector wektor2)
{
float avg1 = 0.0f, avg2 = 0.0f;

if (!wektor1.empty()) {
    for (auto x : wektor1) avg1 += x;
    avg1 /= (float)wektor1.size();
}

if (!wektor2.empty()) {
    for (auto x : wektor2) avg2 += x;
    avg2 /= (float)wektor2.size();
}

size_t a = wektor1.size();
size_t b = wektor2.size();
size_t n = (a < b) ? b : a;

vector<float> wynik(n, 0.0f);

for (size_t i = 0; i < n; i++) {
    float v1 = avg1;
    float v2 = avg2;

    if (i < a) v1 = wektor1[i];
    if (i < b) v2 = wektor2[i];

    wynik[i] = v1 - v2;
}

return wynik;

}

int main() {
std::vector wektor1;
std::vector wektor2;
std::vector wynik;
float input;
while (std::cin >> input) {
wektor1.push_back(input);
if (std::cin.get() == '\n’) {
break;
}
}
while (std::cin >> input) {
wektor2.push_back(input);
if (std::cin.get() == '\n’) {
break;
}
}
wynik = roznicaWektorow(wektor1, wektor2);
for (int i = 0; i < (int)wynik.size(); i++) {
std::cout << wynik[i] << ” „;
}
std::cout << std::endl;
return 0;
}

Kategorie

Ostatnie

Zadanie 2

using namespace std; std::string replaceLastOccurrence(string tekst, string slowo){string pierwsze = „”;bool firstSet = false; } int main(){string tekst, slowo;getline(cin, tekst);getline(cin, slowo);cout << replaceLastOccurrence(tekst, slowo) << endl;return 0;}

Przeczytaj więcej »

Zadanie 1

Wektory dodaj includy using namespace std; vector roznicaWektorow(vector wektor1, vector wektor2){float avg1 = 0.0f, avg2 = 0.0f; } int main() {std::vector wektor1;std::vector wektor2;std::vector wynik;float input;while (std::cin >> input) {wektor1.push_back(input);if (std::cin.get()

Przeczytaj więcej »

Tagi

Kalendarz

kwiecień 2026
P W Ś C P S N
 12345
6789101112
13141516171819
20212223242526
27282930  

Pozostałe Wpisy

Zadanie 4

class Triangle{double _side1, _side2, _side3; public:Triangle(double a = 0, double b = 0, double c = 0) : _side1(a), _side2(b), _side3(c) {} }; int main(){int n;std::cin>>n;Triangle a(0, 0, 0);Triangle b(0, 0, 0);Triangle c(0, 0, 0);double s1, s2, s3;switch (n){case 1:a = Triangle();std::cout<<a.getSide(1)<<std::endl;std::cout<<a.getSide(2)<<std::endl;std::cout<<a.getSide(3)<<std::endl;break; }

Czytaj więcej ➭

Zadanie 3

using namespace std; int count_even_sums_and_sort_list(list& lista){int ile = (int)count_if(lista.begin(), lista.end(), [](int v) {if (v < 0) v = -v; int s = 0; do { s += v % 10; v /= 10; } while (v > 0);return (s % 2) == 0;}); } int main(){std::list lista;int n;while(std::cin>>n)lista.push_back(n); }

Czytaj więcej ➭

Zadanie 2

using namespace std; std::string replaceLastOccurrence(string tekst, string slowo){string pierwsze = „”;bool firstSet = false; } int main(){string tekst, slowo;getline(cin, tekst);getline(cin, slowo);cout << replaceLastOccurrence(tekst, slowo) << endl;return 0;}

Czytaj więcej ➭