Прошу помочь с С++

Discussion in 'С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby' started by ASK.FM, 20 Oct 2013.

  1. ASK.FM

    ASK.FM New Member

    Joined:
    10 Aug 2012
    Messages:
    12
    Likes Received:
    1
    Reputations:
    0
    Добрый день, уважаемые античатовцы. Прошу у вас помощи с программой. Буду благодарен за любую идею.

    [​IMG]
     
    #1 ASK.FM, 20 Oct 2013
    Last edited: 20 Oct 2013
  2. neviens

    neviens Member

    Joined:
    9 Oct 2013
    Messages:
    82
    Likes Received:
    28
    Reputations:
    3
    Идея- дополнить задание описанием функции F().
    Иначе программу написать не возможно.
     
  3. Gar|k

    Gar|k Moderator

    Joined:
    20 Mar 2009
    Messages:
    1,166
    Likes Received:
    266
    Reputations:
    82
    Ну типа эээ

    Code:
    int func(int a, int b,int c) {
     // ввод с клавы
     int x_start = 0;
     int x_end = 100;
     int dx = 1;
     const char format[]="%d: %d\n";
    
     for(int x=x_start;x<x_end;x+=dx) {
       if(a<0 && c !=0)  printf(format,x, (a*(x*x))+b*x+c));
       else if(a>0 && c == 0) printf(format,x,((a * -1)/x-c));
       else printf(format,x,(a*(x+c)));
     }
    
     return (a & (b | c)) != 0 ? действительное значение : целое значение;
    }
     
    _________________________
  4. neviens

    neviens Member

    Joined:
    9 Oct 2013
    Messages:
    82
    Likes Received:
    28
    Reputations:
    3
    >ASK.FM
    Code:
    #include <iostream>
    #include <math.h>
    using namespace std;
    #define EPSILON 1e-8
    
    int main()
    {
    	int ai, bi, ci, isInt;
    	double a, b, c, x, y, xend, dx;
    //----------------------------------do input	
    	cout << "Enter a: "; cin >> a;
    	cout << "Enter b: "; cin >> b;
    	cout << "Enter c: "; cin >> c;
    	cout << "Enter x: "; cin >> x;
    	cout << "Enter xend: "; cin >> xend;
    	cout << "Enter dx: "; cin >> dx;
    	if(((x > xend) && (dx > 0)) || ((x < xend) && (dx < 0)))
    	{
    		cout << "Error: Invalid increment value";
    		return -1;
    	}
    //----------------------------------intpart only, if !(a && (b || c))
    	isInt = 1;
    	for(ai = a, bi = b, ci = c; ;)
    	{
    		if(ai % 10 && (bi %10 || ci % 10)) 
    		{
    			isInt = 0;
    			break;
    		}
    		ai /= 10; bi /= 10; ci /= 10;
    		if(!ai && !bi && !ci)
    			break;
    	}
    //----------------------------------print y=F(a,b,c,x)
    	for( ; x < xend; x += dx)
    	{
    		if(isInt)
    			modf(x, &x);
    		if(a < 0 && abs(c) > EPSILON)
    			y = a * x * x + b * x + c;
    		else if(a > 0 && abs(c) < EPSILON)
    			y = -a / (x - c);
    		else
    			y = (x + c) * a;
    		printf("x = %f, y = %f\n", x, y);
    	}
    	return 0;
    }