consolidate all repos to one for archive

This commit is contained in:
2025-01-28 13:46:42 +01:00
commit a6610fbc7a
5350 changed files with 2705721 additions and 0 deletions

View File

@@ -0,0 +1,121 @@
#include <iostream>
#include <string>
using namespace std;
struct Datum{
int dan, mesec, leto;
};
struct PametnaUra{
string brand;
float cena;
string opSistem;
};
struct Telefon{
string ime;
Datum datum_nakupa;
PametnaUra ura;
float GHz;
string brand;
float cena;
string opSistem;
};
void upis(Telefon *polje[10],int st){
for(int i = 0; i<st; i++){
polje[i] = new Telefon;
cout<<"Ime naprave:";
cin>>polje[i]->ime;
cout<<"Dan nakupa:";
cin>>polje[i]->datum_nakupa.dan;
cout<<"Mesec nakupa:";
cin>>polje[i]->datum_nakupa.mesec;
cout<<"Leto nakupa:";
cin>>polje[i]->datum_nakupa.leto;
cout<<"Brand od ure:";
cin>>polje[i]->ura.brand;
cout<<"Cena ure:";
cin>>polje[i]->ura.cena;
cout<<"Operacijski sistem ure:";
cin>>polje[i]->ura.opSistem;
cout<<"Hitrost procesorja:";
cin>>polje[i]->GHz;
cout<<"Znamka telefona:";
cin>>polje[i]->brand;
cout<<"Cena telefona:";
cin >>polje[i]->cena;
cout<<"Operacijski sistem telefona:";
cin>>polje[i]->opSistem;
cout<<endl<<endl;
}
}
void izpis(Telefon *polje[10],int st){
for(int i = 0; i<st; i++){
cout<<"Ime naprave:"<<polje[i]->ime<<endl;
cout<< "Datum nakupa:";
cout<<polje[i]->datum_nakupa.dan<<".";
cout<<polje[i]->datum_nakupa.mesec<<".";
cout<<polje[i]->datum_nakupa.leto<<endl;
cout<<"Brand od ure:" << polje[i]->ura.brand<<endl;
cout<<"Cena ure:" << polje[i]->ura.cena<<endl;
cout<<"Operacijski sistem ure:" << polje[i]->ura.opSistem<<endl;
cout<<"Hitrost procesorja:" << polje[i]->GHz<<endl;
cout<<"Znamka telefona:" << polje[i]->brand<<endl;
cout<<"Cena telefona" << polje[i]->cena<<endl;
cout<<"Operacijski sistem telefona:" << polje[i]->opSistem<<endl;
cout<<endl<<endl;
}
}
void sort(Telefon *polje[10],int st){
for (int j = 0; j < st; j++){
for (int i = 0; i < st-j-1;i++){
if (polje[i]->datum_nakupa.leto > polje[i+1]->datum_nakupa.leto){
Telefon *tmp;
tmp = polje[i];
polje[i]=polje[i+1];
polje[i+1]=tmp;
}
if (polje[i]->datum_nakupa.leto == polje[i+1]->datum_nakupa.leto){
if (polje[i]->datum_nakupa.mesec > polje[i+1]->datum_nakupa.mesec){
Telefon *tmp;
tmp = polje[i];
polje[i]=polje[i+1];
polje[i+1]=tmp;
}
}
if (polje[i]->datum_nakupa.leto == polje[i+1]->datum_nakupa.leto){
if (polje[i]->datum_nakupa.mesec == polje[i+1]->datum_nakupa.mesec){
if (polje[i]->datum_nakupa.dan > polje[i+1]->datum_nakupa.dan){
Telefon *tmp;
tmp = polje[i];
polje[i]=polje[i+1];
polje[i+1]=tmp;
}
}
}
}
}
}
int main(){
int st = 10;//stevilo telefonov
Telefon *polje[10]; // Ustvarimo polje kazalcev
upis(polje,st);
sort(polje,st);
izpis(polje,st);
// Sprostimo rezerviran pomnilnik
for(int i = 0; i<st; i++){
delete polje[i];
}
return 0;
}