Rasprave u vezi Linux aplikacija.
Moderator/ica: Moderatori/ce
paupav
Postovi: 42 Pridružen/a: 29 lip 2013, 01:07
Spol: M
OS: Elementary OS Freya
Post
Postao/la paupav » 15 srp 2013, 13:58
U biti ona izračunava kolko dani, mjeseci, godina živiš
DOWNLOAD LINK
evo vam kod ako vam nešto ne radi
Kod: Označi sve
#include <iostream>
#include <string>
#include <ctime>
using namespace std;
struct numbers
{
short int day;
short int month;
short int year;
} today, birth, difference;
void lifetimepassed (int, int, int);
int tutToday ();
int tutBirth ();
int error ();
int calculation ();
int clockclock ();
int correcting();
int main()
{
//######################################
clockclock();
cout << "\nSo it is: " << today.day << "." << today.month << "." << today.year << " -formatted in DD.MM.YYYY";
cout << "\nIs that date correct? Wtite 'no' to enter date manually. ";
string correct;
correct = "Yes";
getline (cin,correct);
if (correct == "no")
{
cout << "\nPlease re-enter it ";
tutToday();
}
else
{
cout << "\nSystem date active. ";
}
tutBirth();
cout << "\nSo you were born: " << birth.day << "." << birth.month << "." << birth.year << " -formatted in DD.MM.YYYY";
error ();
calculation ();
lifetimepassed (difference.day, difference.month, difference.year);
//##################################
}
int tutToday()
{
cout << "\nEnter today's day: ";
cin >> today.day;
cout << "Enter today's month: ";
cin >> today.month;
cout << "Enter today's year: ";
cin >> today.year;
return 0;
}
int tutBirth ()
{
cout << "\nEnter your birth day (just number): ";
cin >> birth.day;
cout << "Enter your birth month (just number): ";
cin >> birth.month;
cout << "Enter your birth year (just number): ";
cin >> birth.year;
return 0;
}
int error()
{
while (today.day > 31 || today.month > 12 )
{
cout << "\nThere is some problem with today's date, please re-enter it" << endl;
tutToday();
}
while (birth.day > 31 || birth.month > 12 )
{
cout << "\nThere is some problem with your birth date, please re-enter it" << endl;
tutBirth ();
}
return 0;
}
int calculation ()
{
difference.year = today.year - birth.year ;
//Month conversion
if (today.month < birth.month)
{
difference.year--;
today.month += 12;
}
difference.month = today.month - birth.month ;
if (today.day < birth.day)
{
difference.month--;
today.day += 30;
}
difference.day = today.day - birth.day ;
return 0;
}
int clockclock()
{
time_t t = time(NULL);
tm* timePtr = localtime(&t);
today.day = timePtr->tm_mday;
today.month = timePtr->tm_mon += 1;
today.year = timePtr->tm_year +=1900;
return 0;
}
void lifetimepassed (int a, int b, int c)
{
cout << "\nYou have lived: \n" << difference.day << " days\n" << difference.month << " months\n" << difference.year << "years\n\n";
}
ako neznate kako otvorit *.out datoteku pokazano vam je u slici u privitku
Privitak/ci
how-to.png
(75.02 KiB) Preuzeto 24 puta.
shrike
Moderator
Postovi: 10322 Pridružen/a: 07 pro 2007, 18:07
Spol: Y
OS: utuntu 19.10
Kontakt:
Post
Postao/la shrike » 15 srp 2013, 16:37
Baš se neće iskompajlirat. Daje grešku:
Kod: Označi sve
kolkozivis.cpp:52:91: warning: missing terminating '"' character [-Winvalid-pp-token]
cout << "\nSo you were born: " << birth.day << "." << birth.month << "." << birth.year << " -formatted in
^
kolkozivis.cpp:52:91: error: expected expression
kolkozivis.cpp:53:11: warning: missing terminating '"' character [-Winvalid-pp-token]
DD.MM.YYYY";
^
2 warnings and 1 error generated.
Es gibt keinen Gott, kein Universum, keine menschliche Rasse, kein irdisches Leben, keinen Himmel, keine Hölle. Es ist alles ein Traum - ein grotesker und dummer Traum. Nichts existiert außer dir. Und du bist nur ein Gedanke - ein vagabundierender Gedanke, ein nutzloser Gedanke, ein heimatloser Gedanke, der verloren in der leeren Ewigkeit wandelt!
blacx
Postovi: 1245 Pridružen/a: 22 vel 2012, 12:24
Spol: M
OS: Arch bspwm/KDE
Lokacija: Split
Post
Postao/la blacx » 15 srp 2013, 17:12
Meni radi kompajl.
Jesi dobro kopirao, očito ti fali završni navodnik?
You have lived:
22 days
9 months
24years
paupav
Postovi: 42 Pridružen/a: 29 lip 2013, 01:07
Spol: M
OS: Elementary OS Freya
Post
Postao/la paupav » 15 srp 2013, 18:33
shrike je napisao/la: Baš se neće iskompajlirat. Daje grešku:
Kod: Označi sve
kolkozivis.cpp:52:91: warning: missing terminating '"' character [-Winvalid-pp-token]
cout << "\nSo you were born: " << birth.day << "." << birth.month << "." << birth.year << " -formatted in
^
kolkozivis.cpp:52:91: error: expected expression
kolkozivis.cpp:53:11: warning: missing terminating '"' character [-Winvalid-pp-token]
DD.MM.YYYY";
^
2 warnings and 1 error generated.
čudno. vjerojatno je ovo od osobe iznad mene
You have lived:
26 days
9 months
15years
Medojedni jazavac
Postovi: 1536 Pridružen/a: 22 tra 2012, 08:55
Spol: M
OS: eOS Luna
Lokacija: ForHill Croatia
Kontakt:
Post
Postao/la Medojedni jazavac » 15 srp 2013, 19:01
Daj napravi da mozes birat format outputa. Tipa, samo sekunde, minute, dani, mjeseci, godine. Pa kombinacije i sl.
stefan je napisao/la: tu mač gemišta
To understand recursion, you must first understand recursion.
4ndY
Moderator
Postovi: 4060 Pridružen/a: 15 svi 2008, 18:05
Spol: M
OS: Fedora/KDE
Lokacija: Hamburg, DE
Kontakt:
Post
Postao/la 4ndY » 15 srp 2013, 19:34
Meni isto radi^TM
Medojedni jazavac je napisao/la: Daj napravi da mozes birat format outputa. Tipa, samo sekunde, minute, dani, mjeseci, godine. Pa kombinacije i sl.
Mislim da bi bilo zgodnije i kraće da se sve računa u sistemskom vremenu, a onda se tek na kraju preračuna u željeni format (
hint ).
A neutron walks into a bar; he asks the bartender, 'How much for a beer?' The bartender looks at him, and says 'For you, no charge.'
paupav
Postovi: 42 Pridružen/a: 29 lip 2013, 01:07
Spol: M
OS: Elementary OS Freya
Post
Postao/la paupav » 15 srp 2013, 20:36
Medojedni jazavac je napisao/la: Daj napravi da mozes birat format outputa. Tipa, samo sekunde, minute, dani, mjeseci, godine. Pa kombinacije i sl.
Može ovako?
Kod: Označi sve
#include <iostream>
#include <string>
#include <ctime>
using namespace std;
struct numbers
{
short int day;
short int month;
short int year;
} today, birth, difference;
void lifetimepassed (int, int, int);
int tutToday ();
int tutBirth ();
int error ();
int calculation ();
int clockclock ();
int correcting();
int recalculation ();
int main()
{
//######################################
clockclock();
cout << "\nSo it is: " << today.day << "." << today.month << "." << today.year << " -formatted in DD.MM.YYYY";
cout << "\nIs that date correct? Wtite 'no' to enter date manually. ";
string correct;
correct = "Yes";
getline (cin,correct);
if (correct == "no")
{
cout << "\nPlease re-enter it ";
tutToday();
}
else
{
cout << "\nSystem date active. ";
}
tutBirth();
cout << "\nSo you were born: " << birth.day << "." << birth.month << "." << birth.year << " -formatted in DD.MM.YYYY";
error ();
calculation ();
lifetimepassed (difference.day, difference.month, difference.year);
recalculation ();
//##################################
}
int tutToday()
{
cout << "\nEnter today's day: ";
cin >> today.day;
cout << "Enter today's month: ";
cin >> today.month;
cout << "Enter today's year: ";
cin >> today.year;
return 0;
}
int tutBirth ()
{
cout << "\nEnter your birth day (just number): ";
cin >> birth.day;
cout << "Enter your birth month (just number): ";
cin >> birth.month;
cout << "Enter your birth year (just number): ";
cin >> birth.year;
return 0;
}
int error()
{
while (today.day > 31 || today.month > 12 )
{
cout << "\nThere is some problem with today's date, please re-enter it" << endl;
tutToday();
}
while (birth.day > 31 || birth.month > 12 )
{
cout << "\nThere is some problem with your birth date, please re-enter it" << endl;
tutBirth ();
}
return 0;
}
int calculation ()
{
difference.year = today.year - birth.year ;
//Month conversion
if (today.month < birth.month)
{
difference.year--;
today.month += 12;
}
difference.month = today.month - birth.month ;
if (today.day < birth.day)
{
difference.month--;
today.day += 30;
}
difference.day = today.day - birth.day ;
return 0;
}
int clockclock()
{
time_t t = time(NULL);
tm* timePtr = localtime(&t);
today.day = timePtr->tm_mday;
today.month = timePtr->tm_mon += 1;
today.year = timePtr->tm_year +=1900;
return 0;
}
int recalculation ()
{
int recalcMonth, recalcDay, recalcHou, recalcMin, recalcSec ;
recalcMonth = (difference.year * 12)+ difference.month ;
recalcDay = (recalcMonth * 30) + difference.day;
recalcHou = recalcDay * 24;
recalcMin = recalcHou * 60;
recalcSec = recalcMin * 60;
cout << "\nWhich is \n= " << recalcMonth << " months\n= " << recalcDay << " days\n= " << recalcHou << " hours\n= " << recalcMin << " minutes\n= " << recalcSec << " seconds\n";
return 0;
}
void lifetimepassed (int a, int b, int c)
{
cout << "\nYou have lived: \n" << difference.day << " days\n" << difference.month << " months\n" << difference.year << "years\n\n";
}
DOWNLOAD LINK
Cooleech
Moderator
Postovi: 7039 Pridružen/a: 13 stu 2010, 21:12
Spol: M
OS: Arch Linux KDE
Lokacija: /hrvatska/solin/
Post
Postao/la Cooleech » 15 srp 2013, 20:44
You have lived:
11 days
5 months
35years
Which is
= 425 months
= 12761 days
= 306264 hours
= 18375840 minutes
= 1102550400 seconds
Cool
eech , samo nedostaje razmak kod broja godina
Vl@do je napisao/la: Arch imaš upravo zato da uštediš na vremenu. Nemaš nikakvih problema s instalacijama, kompajliranjem i ostalim. Imaš jednostavno funkcionalan i stabilan, uvijek najsvježiji OS, a osim toga je sexy i cool do neba.
I've seen some idiots back in my time, but you man... you're special!
paupav
Postovi: 42 Pridružen/a: 29 lip 2013, 01:07
Spol: M
OS: Elementary OS Freya
Post
Postao/la paupav » 15 srp 2013, 21:27
Cooleech je napisao/la: You have lived:
11 days
5 months
35years
Which is
= 425 months
= 12761 days
= 306264 hours
= 18375840 minutes
= 1102550400 seconds
Cool
eech , samo nedostaje razmak kod broja godina
hahah evo evo
Kod: Označi sve
#include <iostream>
#include <string>
#include <ctime>
using namespace std;
struct numbers
{
short int day;
short int month;
short int year;
} today, birth, difference;
void lifetimepassed (int, int, int);
int tutToday ();
int tutBirth ();
int error ();
int calculation ();
int clockclock ();
int correcting();
int recalculation ();
int main()
{
//######################################
clockclock();
cout << "\nSo it is: " << today.day << "." << today.month << "." << today.year << " -formatted in DD.MM.YYYY";
cout << "\nIs that date correct? Wtite 'no' to enter date manually. ";
string correct;
correct = "Yes";
getline (cin,correct);
if (correct == "no")
{
cout << "\nPlease re-enter it ";
tutToday();
}
else
{
cout << "\nSystem date active. ";
}
tutBirth();
cout << "\nSo you were born: " << birth.day << "." << birth.month << "." << birth.year << " -formatted in DD.MM.YYYY";
error ();
calculation ();
lifetimepassed (difference.day, difference.month, difference.year);
recalculation ();
//##################################
}
int tutToday()
{
cout << "\nEnter today's day: ";
cin >> today.day;
cout << "Enter today's month: ";
cin >> today.month;
cout << "Enter today's year: ";
cin >> today.year;
return 0;
}
int tutBirth ()
{
cout << "\nEnter your birth day (just number): ";
cin >> birth.day;
cout << "Enter your birth month (just number): ";
cin >> birth.month;
cout << "Enter your birth year (just number): ";
cin >> birth.year;
return 0;
}
int error()
{
while (today.day > 31 || today.month > 12 )
{
cout << "\nThere is some problem with today's date, please re-enter it" << endl;
tutToday();
}
while (birth.day > 31 || birth.month > 12 )
{
cout << "\nThere is some problem with your birth date, please re-enter it" << endl;
tutBirth ();
}
return 0;
}
int calculation ()
{
difference.year = today.year - birth.year ;
//Month conversion
if (today.month < birth.month)
{
difference.year--;
today.month += 12;
}
difference.month = today.month - birth.month ;
if (today.day < birth.day)
{
difference.month--;
today.day += 30;
}
difference.day = today.day - birth.day ;
return 0;
}
int clockclock()
{
time_t t = time(NULL);
tm* timePtr = localtime(&t);
today.day = timePtr->tm_mday;
today.month = timePtr->tm_mon += 1;
today.year = timePtr->tm_year +=1900;
return 0;
}
int recalculation ()
{
int recalcMonth, recalcDay, recalcHou, recalcMin, recalcSec ;
recalcMonth = (difference.year * 12)+ difference.month ;
recalcDay = (recalcMonth * 30) + difference.day;
recalcHou = recalcDay * 24;
recalcMin = recalcHou * 60;
recalcSec = recalcMin * 60;
cout << "\nWhich is \n= " << recalcMonth << " months\n= " << recalcDay << " days\n= " << recalcHou << " hours\n= " << recalcMin << " minutes\n= " << recalcSec << " seconds\n";
return 0;
}
void lifetimepassed (int a, int b, int c)
{
cout << "\nYou have lived: \n" << difference.day << " days\n" << difference.month << " months\n" << difference.year << " years\n\n";
}
P.S mjeseci nisu 100% točni, jer nije u decimalnom zapisu
4ndY
Moderator
Postovi: 4060 Pridružen/a: 15 svi 2008, 18:05
Spol: M
OS: Fedora/KDE
Lokacija: Hamburg, DE
Kontakt:
Post
Postao/la 4ndY » 15 srp 2013, 23:50
Što ako je prijestupna godina ili ako si rođen u prijestupnoj? Falit će jedan dan zar ne? Slično je i sa brojem dana u mjesecu...
A neutron walks into a bar; he asks the bartender, 'How much for a beer?' The bartender looks at him, and says 'For you, no charge.'