Skip to content

Commit

Permalink
03-01-24
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz-stepien-dev committed Jan 3, 2024
1 parent 7b686f3 commit bf02a57
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 0 deletions.
45 changes: 45 additions & 0 deletions 03-01-24/ex1-03-01-23.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <iostream>
#include <ctime>
#include <cstdlib>

using namespace std;

int main() {
int size;
std::cout << "Podaj rozmiar tablicy: ";
std::cin >> size;

srand(time(nullptr));
int *array = new int[size];

for (int i = 0; i < size; i++) {
array[i] = rand() % 100;
cout << array[i] << " ";
}

int largest = array[0];
int smallest = array[0];
double avg = 0;

for (int i = 1; i < size; i++) {
if (array[i] > largest) {
largest = array[i];
}
}
cout << "\nLargest: " << largest << endl;

for (int i = 1; i < size; i++) {
if (array[i] < smallest) {
smallest = array[i];
}
}
cout << "Smallest: " << smallest << endl;

for (int i = 0; i < size; i++) {
avg += array[i];
}
avg /= size;
cout << "Average: " << avg << endl;

delete[] array;
}
41 changes: 41 additions & 0 deletions 03-01-24/ex2-03-01-24.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <iostream>
#include <string>

struct Ksiazka {
std::string tytul;
std::string autor;
int rokWydania;
};

int main() {
std::cout << "Podaj liczbe ksiazek do dodania do biblioteki: ";
int liczbaKsiazek;
std::cin >> liczbaKsiazek;

Ksiazka* biblioteka = new Ksiazka[liczbaKsiazek];

for (int i = 0; i < liczbaKsiazek; ++i) {
std::cout << "Podaj dane dla ksiazki " << i + 1 << ":\n";
std::cout << "Tytul: ";
std::cin.ignore();
std::getline(std::cin, biblioteka[i].tytul);

std::cout << "Autor: ";
std::getline(std::cin, biblioteka[i].autor);

std::cout << "Rok wydania: ";
std::cin >> biblioteka[i].rokWydania;
}

std::cout << "\nInformacje o ksiazkach w bibliotece:\n";
for (int i = 0; i < liczbaKsiazek; ++i) {
std::cout << "Ksiazka " << i + 1 << ":\n";
std::cout << "Tytul: " << biblioteka[i].tytul << "\n";
std::cout << "Autor: " << biblioteka[i].autor << "\n";
std::cout << "Rok wydania: " << biblioteka[i].rokWydania << "\n\n";
}

delete[] biblioteka;

return 0;
}
36 changes: 36 additions & 0 deletions 03-01-24/ex3-03-01-24.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <iostream>
#include <string>

using namespace std;

struct Student {
string name;
string surname;
string degreeCourse;
int age;
int indexNumber;
double avg;
};

int main () {
Student student;
cout << "Wpisz dane studenta: " << endl;
cout << "Imie: ";
cin >> student.name;
cout << "Nazwisko: ";
cin >> student.surname;
cout << "Kierunek studiow: ";
cin >> student.degreeCourse;
cout << "Wiek: ";
cin >> student.age;
cout << "Indeks: ";
cin >> student.indexNumber;
cout << "Srednia ocen: ";
cin >> student.avg;

cout << "Dane studenta: " << endl;
cout << "Imie: " << student.name << endl;
cout << "Nazwisko: " << student.surname << endl;
cout << "Kierunek studiow: " << student.degreeCourse << endl;
cout << "Wiek: " << student.age << endl;
}

0 comments on commit bf02a57

Please sign in to comment.