Witam , wlasnie poprawilem moj Code ( v.1 https://forum.pasja-informatyki.pl/440678/ocena-projektu-poczatkujacego-w-c).
Mam jednak kilka pytan.
1.Do jakich polecen mam dodac std:: zeby moc usunac using namespace std;
2. Czy takie sformatowanie ktorego uzylem jest odpowiednie czy moze jakos inaczej?
3. Co mam zrobic aby moj Code byl"przenosny"(pisany w linuxie-rasbian)
#include <iostream>
#include <unistd.h>
#include <ctime>
#include <stdio.h>
using namespace std;
int main()
{
//zmienne
string start_commend="start"; string start_cin; string answer;
int math; int try_user=0; int guess; int multiplicate; int number;int math_minus;
std::cout << "Witamy w naszej grze!" << endl;
std::cout << "Wpisz start aby rozpoczac!" << endl;
std::cin >> start_cin;
if (start_commend==start_cin)
{
std::cout << "Zaczynamy"<< endl << endl << endl;
}
else
{
std::cout << "Zla komenda! Auto-Start za 30s"<< endl;
sleep (1);
for (int i=29; i>=0; i--)
{
sleep(1); system("clear");
std::cout << i << endl;
}
}
std::cout << "Pomyslalem sobie liczbe od 1..1000" << endl;
std::cout << "Zgadnij co to za liczba :) Oto kilka podpowiedzi" << endl;
srand (time(NULL));
number=rand()%1000+1;
if (number>=500)
{
std::cout<<"Liczba jest wieksza od 500"<< endl;
}
else
{
std::cout << "Liczba jest mniejsza niz 500" << endl;
}
if (number%2 != 1)
{
std::cout << "Liczba jest podzielna przez 2" << endl;
}
else
{
std::cout << "Liczba nie jest podzielna przez 2" << endl << endl;
}
std::cout<<"Lubisz Matematyke? (tak/nie)";
std::cin >> answer;
if(answer=="tak")
{
srand (time(NULL));
multiplicate=rand()%100+1;
srand (time(NULL));
math_minus=rand()%1000+1;
math = multiplicate*number-math_minus;
std::cout << "Jesli pomnozysz te liczbe przez "<< multiplicate << " i odejmiesz " << math_minus << " to wynik bedzie rowny "<< math << endl;
}
else
{
std::cout << "Szkoda :( ";
}
while(guess!=number)
{
try_user ++;
std::cout<<"( "<<try_user<< ". Proba )Ok to jaka to liczba: ";
std::cin >> guess;
if(guess==number)
std::cout<<"Wygrales w "<<try_user<<" probie! :D"<< endl;
if(guess<number)
std::cout<<"to za malo"<< endl;
if(guess>number)
std::cout<<"To za duzo"<< endl;
}
getchar();getchar();
return 0;
}