rogram trojkat
i arcim w dniu Sunday, 4 November 2007, 07:36 napisał(a)
#include <iostream.h>
#include <math.h>
int main()
{
int a,b,c;
float p=0;
cout << "podaj a ";
cin >>a;
cout << "podaj b ";
cin >>b;
cout << "podaj c ";
cin >>c;
if (((a+b)>c) && ((a+c)>b) && ((b+c)>a) && (a>0) && (b>0) && (c>0))
{ p=(a+b+c) / 2.0;
cout <<"pole = "<<sqrt(p*(p-a)*(p-b)*(p-c))<<endl; }
else cout << "to nie jest trojkat ";
system("PAUSE");
retirn 0;
}
23.12.2007 - Ćwiczenia Emil Romanowski w dniu niedziela, 23 grudzień 2007, 10:38 napisał(a) |
---|
Odp: 23.12.2007 - Ćwiczenia Tomasz Bielecki w dniu niedziela, 23 grudzień 2007, 11:17 napisał(a) |
|
---|---|
//-------------------------------------------------------------------------- |
Odp: 23.12.2007 - Ćwiczenia Emil Romanowski w dniu niedziela, 23 grudzień 2007, 11:42 napisał(a) |
|
---|---|
#include <cstdlib> using namespace std; //silnia iteracyjna { if (n<=1) return 1; int main(int argc, char *argv[]) { |-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-| #include <cstdlib> using namespace std; //silnia rekurencyjna { int main(int argc, char *argv[]) { |
2008.01.12 Potęga rekurencyjnie
Małgorzata Kasprzak w dniu Saturday, 12 January 2008, 11:52 napisał(a)
//---//---------------------------------------------------------------------------
#pragma hdrstop
//---------------------------------------------------------------------------
#include<iostream.h>
#pragma argsused
float potega(float a, int n)
{ if(n<1) return 1;
else return potega(a,n-1)*a;
}
int main(int argc, char* argv[])
{ float a; int n;
cout<<"Podaj a";
cin>> a;
cout<<"Podaj n";
cin>> n;
cout<<"Wynik "<<potega(a,n)<<endl;
system("PAUSE");
return 0;
}
12.01.2008 Michał Karkocha w dniu Saturday, 12 January 2008, 11:21 napisał(a) |
---|
Odp: 12.01.2008 Michał Karkocha w dniu Saturday, 12 January 2008, 11:50 napisał(a) |
|
---|---|
//--------------------------------------------------------------------------- |
Odp: 12.01.2008 Michał Karkocha w dniu Saturday, 12 January 2008, 12:06 napisał(a) |
|
---|---|
MAX |
Odp: 12.01.2008 Michał Karkocha w dniu Saturday, 12 January 2008, 12:11 napisał(a) |
|
---|---|
max z 3 liczb |
Odp: 12.01.2008 Michał Karkocha w dniu Saturday, 12 January 2008, 12:37 napisał(a) |
|
---|---|
przekazywanie parametrów przez referencje |
Suma szeregu n Paweł Kuczyński w dniu Saturday, 12 January 2008, 12:59 napisał(a) |
|
---|---|
Suma szeregu n |
Suma 1+ 1/2 +1/3 .... +1/n Paweł Kuczyński w dniu Saturday, 12 January 2008, 13:10 napisał(a) |
|
---|---|
float suma(float n) |
Funkcja licząca elementy ciągu Fibbonaciego Tomasz Bielecki w dniu Saturday, 12 January 2008, 13:30 napisał(a) |
|
---|---|
Funkcja licząca elementy ciągu Fibbonaciego //--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include <iostream.h> //--------------------------------------------------------------------------- #pragma argsused int fib(int n) { if (n<3) return 1; else return fib(n-1)+fib(n-2); } int main(int argc, char *argv[]) { int n; cout<<"podaj n"; cin>>n; for (int i=1;i<=n;i++) cout <<i<<"f="<<fib(i)<<endl; system("PAUSE"); return EXIT_SUCCESS; } //--------------------------------------------------------------------------- |
01.Marca.2008 zadania
Krzysztof Kościński w dniu Saturday, 1 March 2008, 15:33 napisał(a)
//---------------------------------------------------------------------------
#pragma hdrstop
#include<iostream.h>
#include<math.h>
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
struct Punkt
{
int x;
int y;
};
Punkt A,B;
cout<<"podaj współrzędne x dla punktu A";
cin>>A.x;
cout<<"podaj współrzędne y dla punktu A";
cin>>A.y;
cout<<"podaj współrzędne x dla punktu B";
cin>>B.x;
cout<<"podaj współrzędne y dla punktu B";
cin>>B.y;
cout<<"A=("<<A.x<<","<<A.y<<")"<<endl;
cout<<"B=("<<B.x<<","<<B.y<<")"<<endl;
cout<<"odległość pomiędzy punktami"<<sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y))<<endl;
system("pause");
return 0;
}
//---------------------------------------------------------------------------
zadanie 2 2008,Marzec.01
Krzysztof Kościński w dniu Saturday, 1 March 2008, 15:56 napisał(a)
//---------------------------------------------------------------------------
#pragma hdrstop
#include<iostream.h>
#include<math.h>
//---------------------------------------------------------------------------
class Punkt
{public:
int x;
int y;
float odl (Punkt B){return sqrt((x-B.x)*(x-B.x)+(y-B.y)*(y-B.y));};
};
#pragma argsused
int main(int argc, char* argv[])
{
Punkt A,B;
cout<<"podaj wspulrzedne x dla punktu A";
cin>>A.x;
cout<<"podaj wspulrzedne y dla punktu A";
cin>>A.y;
cout<<"podaj wspulrzedne x dla punktu B";
cin>>B.x;
cout<<"podaj wspulrzedne y dla punktu B";
cin>>B.y;
cout<<"A=("<<A.x<<","<<A.y<<")"<<endl;
cout<<"B=("<<B.x<<","<<B.y<<")"<<endl;
cout<<"odległos"<<A.odl(B);
system("pause");
return 0;
}
//---------------------------------------------------------------------------
Programowanie 01/03/2008 Tomasz Bielecki w dniu Saturday, 1 March 2008, 15:33 napisał(a) |
---|
Odp: Programowanie 01/03/2008 Tomasz Bielecki w dniu Saturday, 1 March 2008, 16:02 napisał(a) |
|
---|---|
//--------------------------------------------------------------------------- |
Odp: Programowanie 01/03/2008 Tomasz Bielecki w dniu Saturday, 1 March 2008, 16:27 napisał(a) |
|
---|---|
//--------------------------------------------------------------------------- #include <math.h> #include <vcl.h> #pragma hdrstop #include <iostream.h> //--------------------------------------------------------------------------- #pragma argsused class punkt {int x; int y; public : void wypisz(){cout<<"("<<x<<","<<y<<")"<<endl;} float odl(punkt B){return sqrt((x-B.x)*(x-B.x)+(y-B.y)*(y-B.y));} void ustaw(int a, int b) {x=a;y=b;} }; punkt A,B; int main(int argc, char* argv[]) { int a,b; cout<<"podaj x dla A "; cin>>a; cout<<"podaj y dla A "; cin>>b; A.ustaw(a,b); cout<<"podaj x dla B "; cin>>a; cout<<"podaj y dla B "; cin>>b; B.ustaw(a,b); cout<<"odleglosc "<<A.odl(B)<<endl; cout<<"A"; A.wypisz(); cout<<"B"; B.wypisz(); system("PAUSE"); return 0; } //--------------------------------------------------------------------------- |
06.04.2008 Lekcja Tomasz Bielecki w dniu Sunday, 6 April 2008, 13:56 napisał(a) |
---|
Odp: 06.04.2008 Lekcja Mariusz Janowski w dniu Sunday, 6 April 2008, 14:01 napisał(a) |
|
---|---|
a teraz w DEV_C++ #include <cstdlib> using namespace std; { |
|
Praca domowa 01.03.2008 Łukasz Petrykowski w dniu Saturday, 1 March 2008, 16:53 napisał(a) |
|
Napisać klasę prostokąt z metodami: |
Praca domowa - rozwiązanie (06.04.2008) Artur Kunicki w dniu Sunday, 6 April 2008, 12:36 napisał(a) |
|
---|---|
#include <vcl.h> |
|
Odp: Praca domowa 01.03.2008 Łukasz Petrykowski w dniu Sunday, 6 April 2008, 12:44 napisał(a) |
|
//--------------------------------------------------------------------------- |
![]() |
Odp: Praca domowa 01.03.2008 Tomasz Bielecki w dniu Sunday, 6 April 2008, 12:45 napisał(a) |
---|---|
A to inne //--------------------------------------------------------------------------- #include <iostream.h> #include <vcl.h> #pragma hdrstop //--------------------------------------------------------------------------- #pragma argsused class prost {int a; int b; public : prost(){a=1; b=3;} void wypisz(){cout<<"prostokat o bokach "<<a<<","<<b<<endl;} int pole() {return a*b;} int obw() {return 2*(a+b);} void ustaw(int x, int y) {a=x;b=y;} }; prost p1; int main(int argc, char* argv[]) {int x,y; p1.wypisz(); cout<<"podaj bok a="; cin>>x; cout<<"podaj bok b="; cin>>y; p1.ustaw(x,y); p1.wypisz(); cout<<"pole="<<p1.pole()<<endl; cout<<"obwod="<<p1.obw()<<endl; system("PAUSE"); return 0; } //--------------------------------------------------------------------------- |
zad3 01032008
Łukasz Petrykowski w dniu Saturday, 1 March 2008, 16:39 napisał(a)
//---------------------------------------------------------------------------
#include <math.h>
#include <vcl.h>
#pragma hdrstop
#include <iostream.h>
//---------------------------------------------------------------------------
#pragma argsused
class punkt
{ int x;
int y;
public :
void wypisz(){cout<<"("<<x<<","<<y<<")"<<endl;}
float odl(punkt B){return sqrt((x-B.x)*(x-B.x)+(y-B.y)*(y-B.y));}
void ustaw(int a, int b) {x=a;y=b;}
};
punkt A,B;
int main(int argc, char* argv[])
{ int a,b;
cout<<"podaj x dla A ";
cin>>a;
cout<<"podaj y dla A ";
cin>>b;
A.ustaw(a,b);
cout<<"podaj x dla B ";
cin>>a;
cout<<"podaj y dla B ";
cin>>b;
B.ustaw(a,b);
cout<<"odleglosc "<<A.odl(B)<<endl;
cout<<"A"; A.wypisz();
cout<<"B"; B.wypisz();
system("PAUSE");
return 0;
}
//--------------------------------------------------------------------------
20-04-2008 Lekcja Tomasz Bielecki w dniu Sunday, 20 April 2008, 12:18 napisał(a) |
---|
![]() |
Odp: 20-04-2008 Lekcja Tomasz Bielecki w dniu Sunday, 20 April 2008, 13:24 napisał(a) |
---|---|
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include <iostream.h> #include <math.h> //--------------------------------------------------------------------------- #pragma argsused class punkt { protected: float x,y; public: punkt(){x=0; y=0;} punkt(float X, float Y){x=X; y=Y;} void ustawx(float X){x=X;} void ustawy(float Y){y=Y;} float X() {return x;} float Y() {return y;} float odl(punkt p) {sqrt((x-p.X())*(x-p.X())+(y-p.Y())*(y-p.Y()));} }; class okrag: public punkt { protected: float r; public: okrag() {r=1;} okrag(float X, float Y, float R):punkt(X,Y){r=R;} float pole() {return M_PI*r*r;} float obw() {return 2*M_PI*r;} float R() {return r;} void ustawr(float R) {r=R;} }; okrag O1,O2(10,10,20); int main(int argc, char* argv[]) { cout<<"okrag 1 pole="<<O1.pole()<<" obwod="<<O1.obw()<<endl; cout<<"okrag 2 pole="<<O2.pole()<<" obwod="<<O2.obw()<<endl; system("PAUSE"); return 0; } //--------------------------------------------------------------------------- |