Created
February 26, 2022 19:32
-
-
Save kristiker/62a048bba41a5fbda62550bed900637e to your computer and use it in GitHub Desktop.
Provim C++
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
kenge1 3.1 kenge2 2.9 kenge3 4.4 neser 2.8 kurre 3.3332 |
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
#include <ctime> | |
#include <fstream> | |
#include <string> | |
#include <vector> | |
#include <stdlib.h> | |
using namespace std; | |
class Album{ | |
public: | |
time_t dalja; | |
double kohezgjatja; | |
Album(){ | |
this->dalja = time(0); | |
} | |
Album(time_t dalja, double kohezgjatja){ | |
this->dalja = dalja; | |
this->kohezgjatja = kohezgjatja; | |
} | |
bool operator >(Album& tjetri); | |
}; | |
bool Album:: operator >(Album& tjetri){ | |
if(this->dalja > tjetri.dalja) | |
return true; | |
return false; | |
} | |
struct Kenge{ | |
string kengetari; | |
string kohezgjatja; | |
}; | |
class Album_Kengesh{ | |
public: | |
string titulli; | |
vector<Kenge> kenget; | |
Album_Kengesh(){ | |
titulli = "Unknown album"; | |
// Lexo kenget nga skedari | |
ifstream f("kenget.txt"); | |
if (f.is_open()) | |
{ | |
Kenge k; | |
while (getline(f, k.kengetari, ' ')) { | |
getline(f, k.kohezgjatja, ' '); | |
kenget.push_back(k); | |
} | |
f.close(); | |
} | |
} | |
void printo(){ | |
printf("Titulli: %s\n", this->titulli.c_str()); | |
printf("Numri i kengeve: %i\n", this->kenget.size()); | |
for(Kenge kenge: this->kenget){ | |
printf("\t%s (%s)\n", kenge.kengetari.c_str(), kenge.kohezgjatja.c_str()); | |
} | |
} | |
}; | |
int main(){ | |
Album a(time(0), 3.999); | |
Album b(); | |
Album_Kengesh c; | |
//printf("Album dale me %.24s me kohezgjatje %f", ctime(&a.dalja), a.kohezgjatja); | |
c.printo(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment