__________________________________________________________________
Oblicza kod binarny cyfr
program zmiana;
uses crt;
var w:string;
l:integer;
Begin
clrscr;
readln(l);
repeat
if l mod 2=0 then w:='0'+w
else w:='1'+w;
l:=l div 2;
until l=0;
writeln(w);
readln;
end.
___________________________________________________________________
Pokazuje inicjały z imienia i nazwiska
#include <iostream>
using namespace std;
string a,b;
int main()
{
cout << "Podaj imie" << endl;
cin >>a;
cout <<"Podaj nazwisko"<<endl;
cin >>b;
cout<<"Twoje inicjały to: "<<a[0]<<"."<<b[0]<<"."<<endl;
return 0;
}
.........................................................................................................................
Oblicza wiek w dniach godzinach minutach i sekundach
zad 2.
#include <iostream>
using namespace std;
int a;
int b,c,d;
long int e;
int main()
{
cout << "Podaj swoj wiek w latach" << endl;
cin >>a;
b=a*365;
c=a*365*24;
d=a*365*24*60;
e=a*365*24*60*60;
cout <<"Zyjesz "<<b<<" dni"<<endl;
cout <<"Zyjesz "<<c<<" godzin"<<endl;
cout <<"Zyjesz "<<d<<" minut"<<endl;
cout <<"Zyjesz "<<e<<" sekund"<<endl;
return 0;
}
........................................................................................................................................
Oblicza objętość kuli ziemskiej
#include <iostream>
#include <math.h>
using namespace std;
float a,b;
int main()
{
cout << "Podaj promien kuli ziemskiej" << endl;
cin>>a;
if(a!=6378)
cout<<"pomyliles sie";
else{b=4/3*M_PI*pow(a,3);
cout <<"objetosc kuli ziemskiej wynosi: "<<b;
}
return 0;
}
..............................................................................................................................
Oblicza pole trójkąta po podaniu boku "a"
#include <iostream>
#include <math.h>
using namespace std;
float a,pole;
int main()
{
cout << "Podaj a: " << endl;
cin>>a;
if(a<=0)
{
cout << "Trojkat o podanym boku nie istnieje";
}
else
{
pole=(sqrt(3)/4*a*a);
cout<<"pole jest rowne: "<<pole;
}
return 0;
}
-------------------------------------------------------------------------------------
Kalkulator v1.0
#include <iostream>
#include <windows.h>
#include <math.h>
using namespace std;
long double x,y;
int main()
{
cout << "Kalkulator v1.0" << endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),6);
cout << "a";
cout << "Podaj pierwsza liczbe x: " << endl;
cin >> x;
cout << "Podaj druga liczbe y: " << endl;
cin >> y;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),10);
cout << "Suma: " << x+y << endl;
cout << "Roznica: " << x-y << endl;
cout << "Iloczyn: " << x*y << endl;
if (y==0)
{
cout << "Nie dziel cholero przez zero" ;
}
else
{
cout << "Iloraz: " << x/y << endl;
}
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),12);
cout << endl <<"Pierwiastek z liczby x: "<<sqrt(x);
cout << endl <<"Pierwiastek z liczby y: "<<sqrt(y);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),4);
cout << endl <<"Kwadrat x: " << pow(x,2);
cout << endl <<"Kwadrat y: " << pow(y,2);
cout << endl <<"Szescian x: " << pow(x,3);
cout << endl <<"Szescian y: " << pow(y,3);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0);
return 0;
}
--------------------------------------------------------------------------------------