Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*#include <iostream>
- using namespace std;
- void swap(float&, float&);
- void sort(float&, float&, float&);
- int main ()
- {
- float a =5.67;
- float b = 3.45;
- float c = 7.89;
- sort(a,b,c);
- cout<<a<<" "<<b<<" "<<c<<endl;
- system ("pause");
- return 0;
- }
- void sort(float& u, float &v, float &w)
- {
- if (u>v)
- swap (u,v);
- if (u>w)
- swap(u,w);
- if (v>w)
- swap(v,w);
- }
- void swap(float& x, float& y)
- {
- float pom = x;
- x = y;
- y = pom;
- }
- */
- /*#include <iostream>
- using namespace std;
- void NZD_NZS (int, int, int&, int&);
- int main ()
- {
- int a,b,NZD=1, NZS=1;
- cout<<"Vnesete dva prirodni broevi: ";
- cin>>a>>b;
- NZD_NZS(a,b,NZD,NZS);
- cout<<"Za broevite "<<a<<" i "<<b<<endl;
- cout<<"NZD = "<<NZD<<endl<<"NZS = "<<NZS<<endl;
- cout<<endl;
- system ("Color 17");
- system ("pause");
- return 0;
- }
- void NZD_NZS (int broj1,int broj2, int & NZD, int & NZS)
- {
- int delitel, cekor;
- if (broj1 < broj2)
- {
- NZD = NZS = broj1;
- delitel = broj2;
- }
- else
- {
- NZD = NZS = broj2;
- delitel = broj1;
- }
- while (broj1 % NZD !=0 || broj2%NZD !=0)
- NZD--;
- cekor = NZS;
- while (NZS % delitel !=0)
- NZS += cekor;
- }
- */
- #include <iostream>
- using namespace std;
- int Faktoriel (int n)
- {
- int f = 1;
- for (int k =1; k<=n; k++)
- f=f*k;
- return f;
- }
- void BinKo(int n, int k, float & binkoeficient)
- {
- binkoeficient = (1.0)*Faktoriel(n)/(Faktoriel(k)*Faktoriel(n-k));
- }
- void main ()
- {
- int n,i,k;
- float binomenKoeficient;
- cout<<"Vnesete go n=";
- cin>>n;
- cout<<"1"<<endl;
- for (i=1;i<=n;i++)
- {
- cout<<"1 ";
- for (k=1;k<i-1;k++)
- {
- BinKo(i,k,binomenKoeficient);
- cout<<binomenKoeficient<<" ";
- }
- cout<<"1"<<endl;
- }
- system ("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement