Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. /*#include <iostream>
  2. using namespace std;
  3. void swap(float&, float&);
  4. void sort(float&, float&, float&);
  5.  
  6. int main ()
  7. {
  8. float a =5.67;
  9. float b = 3.45;
  10. float c = 7.89;
  11. sort(a,b,c);
  12. cout<<a<<" "<<b<<" "<<c<<endl;
  13. system ("pause");
  14. return 0;
  15. }
  16.  
  17. void sort(float& u, float &v, float &w)
  18. {
  19. if (u>v)
  20. swap (u,v);
  21. if (u>w)
  22. swap(u,w);
  23. if (v>w)
  24. swap(v,w);
  25. }
  26.  
  27. void swap(float& x, float& y)
  28. {
  29. float pom = x;
  30. x = y;
  31. y = pom;
  32. }
  33. */
  34.  
  35.  
  36. /*#include <iostream>
  37. using namespace std;
  38. void NZD_NZS (int, int, int&, int&);
  39.  
  40. int main ()
  41. {
  42. int a,b,NZD=1, NZS=1;
  43. cout<<"Vnesete dva prirodni broevi: ";
  44. cin>>a>>b;
  45.  
  46. NZD_NZS(a,b,NZD,NZS);
  47. cout<<"Za broevite "<<a<<" i "<<b<<endl;
  48. cout<<"NZD = "<<NZD<<endl<<"NZS = "<<NZS<<endl;
  49.  
  50. cout<<endl;
  51. system ("Color 17");
  52. system ("pause");
  53. return 0;
  54. }
  55.  
  56. void NZD_NZS (int broj1,int broj2, int & NZD, int & NZS)
  57. {
  58. int delitel, cekor;
  59. if (broj1 < broj2)
  60. {
  61. NZD = NZS = broj1;
  62. delitel = broj2;
  63. }
  64. else
  65. {
  66. NZD = NZS = broj2;
  67. delitel = broj1;
  68. }
  69. while (broj1 % NZD !=0 || broj2%NZD !=0)
  70. NZD--;
  71. cekor = NZS;
  72. while (NZS % delitel !=0)
  73. NZS += cekor;
  74. }
  75. */
  76.  
  77.  
  78.  
  79. #include <iostream>
  80. using namespace std;
  81.  
  82. int Faktoriel (int n)
  83. {
  84. int f = 1;
  85. for (int k =1; k<=n; k++)
  86. f=f*k;
  87. return f;
  88. }
  89.  
  90. void BinKo(int n, int k, float & binkoeficient)
  91. {
  92. binkoeficient = (1.0)*Faktoriel(n)/(Faktoriel(k)*Faktoriel(n-k));
  93. }
  94.  
  95. void main ()
  96. {
  97. int n,i,k;
  98. float binomenKoeficient;
  99. cout<<"Vnesete go n=";
  100. cin>>n;
  101. cout<<"1"<<endl;
  102. for (i=1;i<=n;i++)
  103. {
  104. cout<<"1 ";
  105. for (k=1;k<i-1;k++)
  106. {
  107. BinKo(i,k,binomenKoeficient);
  108. cout<<binomenKoeficient<<" ";
  109. }
  110. cout<<"1"<<endl;
  111.  
  112.  
  113. }
  114. system ("pause");
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement