Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- #include<stdlib.h>
- int a,b,c;
- float d,x1r,x2r,x1u,x2u;
- int main(){
- printf("Podaj a\n");
- scanf_s("%d",&a);
- printf("Podaj b\n");
- scanf_s("%d",&b);
- printf("Podaj c\n");
- scanf_s("%d",&c);
- system("cls");
- printf("Wzor: ");
- if((a>0)&&(a!=1)){
- printf("%dxx",a);
- }
- if(a==1){
- printf("xx");
- }
- if((a<0)&&(a!=-1)){
- printf("%dxx",a);
- }
- if(a==-1){
- printf("-xx");
- }
- if((a!=0)&&(b>0)&&(b!=1)){
- printf("+%dx",b);
- }
- if((a==0)&&(b>0)&&(b!=1)){
- printf("%dx",b);
- }
- if((b==1)&&(a!=0)){
- printf("+x");
- }
- if((b==1)&&(a==0)){
- printf("x");
- }
- if((b<0)&&(b!=-1)){
- printf("%dx",b);
- }
- if(b==-1){
- printf("-x");
- }
- if(((a!=0)||(b!=0))&&(c!=0)&&(c>0)){
- printf("+%d",c);
- }
- if((a==0)&&(b==0)&&(c!=0)&&(c>0)){
- printf("%d",c);
- }
- if(c<0){
- printf("%d",c);
- }
- if((a==0)&&(b==0)&&(c==0)){
- printf("%d",c);
- }
- printf("=0\n");
- if((a==0)&&(b!=0)){
- x1r=(float)-c/b;
- printf("\nx1 =%f",x1r);
- system("pause");
- }
- if((a==0)&&(b==0)&&(c!=0)){
- printf("Rownanie sprzeczne");
- system("pause");
- }
- if((a==0)&&(b==0)&&(c==0)){
- printf("rownanie tozsamosciowe");
- system("pause");
- }
- if(a!=0){
- d=b*b-4*a*c;
- }
- if(d>0){
- x1r=(-b-sqrt(d))/(2*a);
- x2r=(-b+sqrt(d))/(2*a);
- printf("x1=%f\n",x1r);
- printf("x2=%f\n",x2r);
- system("pause");
- }
- if(d==0){
- x1r=(float)-b/(2*a);
- printf("x1=%f\n",x1r);
- system("pause");
- }
- if(d<0){
- x1r=(float)-b/(2*a);
- x2r=x1r;
- x1u=-(sqrt(abs(d)))/(2*a);
- x2u=-x1u;
- if(x1u<0){
- printf("\n%f%f*i\n",x1r,x1u);
- }
- else
- {
- printf("\n%f+%f*i\n",x1r,x1u);
- }
- if(x2u<0){
- printf("%f%f*i\n",x2r,x2u);
- }
- else
- {
- printf("%f+%f*i\n",x2r,x2u);
- }
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement