Advertisement
Carnby1021

Untitled

Mar 20th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. #include<stdlib.h>
  4.  
  5.  
  6. int a,b,c;
  7. float d,x1r,x2r,x1u,x2u;
  8.  
  9. int main(){
  10.  
  11. printf("Podaj a\n");
  12. scanf_s("%d",&a);
  13. printf("Podaj b\n");
  14. scanf_s("%d",&b);
  15. printf("Podaj c\n");
  16. scanf_s("%d",&c);
  17. system("cls");
  18. printf("Wzor: ");
  19.  
  20. if((a>0)&&(a!=1)){
  21. printf("%dxx",a);
  22. }
  23. if(a==1){
  24. printf("xx");
  25. }
  26. if((a<0)&&(a!=-1)){
  27. printf("%dxx",a);
  28. }
  29. if(a==-1){
  30. printf("-xx");
  31. }
  32.  
  33. if((a!=0)&&(b>0)&&(b!=1)){
  34. printf("+%dx",b);
  35. }
  36. if((a==0)&&(b>0)&&(b!=1)){
  37. printf("%dx",b);
  38. }
  39. if((b==1)&&(a!=0)){
  40. printf("+x");
  41. }
  42. if((b==1)&&(a==0)){
  43. printf("x");
  44. }
  45. if((b<0)&&(b!=-1)){
  46. printf("%dx",b);
  47. }
  48. if(b==-1){
  49. printf("-x");
  50. }
  51.  
  52. if(((a!=0)||(b!=0))&&(c!=0)&&(c>0)){
  53. printf("+%d",c);
  54. }
  55. if((a==0)&&(b==0)&&(c!=0)&&(c>0)){
  56. printf("%d",c);
  57. }
  58. if(c<0){
  59. printf("%d",c);
  60. }
  61. if((a==0)&&(b==0)&&(c==0)){
  62. printf("%d",c);
  63. }
  64. printf("=0\n");
  65.  
  66. if((a==0)&&(b!=0)){
  67. x1r=(float)-c/b;
  68. printf("\nx1 =%f",x1r);
  69. system("pause");
  70. }
  71.  
  72. if((a==0)&&(b==0)&&(c!=0)){
  73. printf("Rownanie sprzeczne");
  74. system("pause");
  75. }
  76. if((a==0)&&(b==0)&&(c==0)){
  77. printf("rownanie tozsamosciowe");
  78. system("pause");
  79. }
  80.  
  81. if(a!=0){
  82. d=b*b-4*a*c;
  83. }
  84.  
  85. if(d>0){
  86. x1r=(-b-sqrt(d))/(2*a);
  87. x2r=(-b+sqrt(d))/(2*a);
  88. printf("x1=%f\n",x1r);
  89. printf("x2=%f\n",x2r);
  90. system("pause");
  91. }
  92. if(d==0){
  93. x1r=(float)-b/(2*a);
  94. printf("x1=%f\n",x1r);
  95. system("pause");
  96. }
  97. if(d<0){
  98. x1r=(float)-b/(2*a);
  99. x2r=x1r;
  100. x1u=-(sqrt(abs(d)))/(2*a);
  101. x2u=-x1u;
  102. if(x1u<0){
  103. printf("\n%f%f*i\n",x1r,x1u);
  104. }
  105. else
  106. {
  107. printf("\n%f+%f*i\n",x1r,x1u);
  108. }
  109. if(x2u<0){
  110. printf("%f%f*i\n",x2r,x2u);
  111. }
  112. else
  113. {
  114. printf("%f+%f*i\n",x2r,x2u);
  115. }
  116. }
  117.  
  118. system("pause");
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement