Results 1 to 3 of 3

Thread: .

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Jan:2010
    Location:
    Posts: 116

    .

    .. (- 54 ) 1-2 . ax^2 +bx+c=0 . :
    Code:
    #include<stdlib.h>
    #include<math.h>
    #include<stdio.h>
    #include<Windows.h>
    
    int main()
    {
    	// 
    int a,b,c,D,x,x1,x2;
    
    SetConsoleOutputCP(1251); 
    	
    	printf(" a:");
    		scanf("%f", &a);
    	printf(" b:");
    		scanf("%f", &b);
    	printf(" c:");
    		scanf("%f", &c);
    
    	//    
    	if(a==0)
    		{
    				printf("  !\n");
    
    					x=b/c;
    				printf("x=%f\n",x);
    	
    system("pause");
    return 0;
    		}	
    
    	D = b*b - 4*a*c;
    	printf("d=%f \n", D);
    
    	//      D
    	if (D<0)
    		{
    			printf("    !\n");
    		}
    	else if (D>0)
    		{
    
    			x1 = (-b + sqrt(D))/(2*a);
    				printf("x1=%f \n", x1);
    			x2 = (-b - sqrt(D))/(2*a);
    				printf("x2=%f \n", x2);
    
    		}
    	else if (D==0)
    		{
    			printf("   :\n");
    			x = (-b + sqrt(D)/(2*a));
    			printf("x1=x2=%f\n",x);
    		}
    
    system("pause");
    return 0;
    }
    , , (1.000000) .000 , . , ( int , float) .

    : - int . , - float (4/5^2+....) ..

    .

  2. #2
    Registered User jjjjjk's Avatar
    Join Date: Nov:2009
    Location: Nowhere
    Posts: 4,079
    printf("%.3f", x1);
    x1 float, a .3f
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
     {
    	float x1 = 7.55552;
    	printf("%.3f", x1);
    	return 0;
    }
    3 7,556. C - , C++ -.
    De jure de facto - !
    , , , , , !

  3. #3
    Registered User
    Join Date: Jan:2010
    Location:
    Posts: 116
    .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |