-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b686f3
commit bf02a57
Showing
3 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |