English 中文(简体)
试图汇编我的C++方案。
原标题:trying to compile my C++ program.
  • 时间:2010-11-08 17:25:03
  •  标签:
  • c++builder

这一方案“FindMIn”具有两种价值,其参数和价值最小。 我试图改变我的方案,以便它以三个价值作为参数,并且回报三个价值中最小的数值。 这正是我迄今为止如何呢?

#include <iostream>        
using namespace std; 
  

//function prototypes go before main - parameters much match those of the function definition

int FindMin(int x, int y);

//place prototype for PrintOutput here

int main()
{
    int n1, n2, n3;
    int result;
    char answ =  Y ;

    while (answ ==  Y )
    {
        cout << "Please enter three numbers..." << endl;
        cin >> n1 >> n2 >> n3;
        result = FindMin(n1, n2); //function call
        
        //place call to function PrintOutput here

        cout << "Would you like to run the program again?  Enter Y or N" << endl;
        cin >> answ;
     }
    

    return(0);
}

//***************************************************************
//FindMin - returns the minimum of two values
//***************************************************************
int FindMin(int a, int b)
{
    if (a < b)
        return a;
    else
        return b;
}
//******************************************************************
//PrintOutput - prints the values input and the smallest of the 
//three values
//******************************************************************
void PrintOutput(int first, int second, int min)
{
    cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
    cout << "The minimum value of " << first << ", " <<
        second << ", is "  << min << endl;
    cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
}
问题回答

Work it out on paper first.

请指出:<代码>1 2 3。

页: 1 你可以直接利用这一职能,因为只有两个论点——但你可以以另一种方式来组成这一职务,使你最少获得3个。 这是基本的数学功能使用。

这里指的是:

min(1,2) = 1
min(1,3) = 1
min(2,3) = 2
min(1,min(2,3)) = 1

你们需要扩大“智商”参数,以吸收三个方面:

int FindMin(int x, int y, int z);

// ...

int main()
{
  // ...
        cin >> n1 >> n2 >> n3;
        result = FindMin(n1, n2, n3); //function call
  // ...
}

// ...

int FindMin(int x, int y, int z)
{
  // Place the code that compares the three numbers and returns minimum here
}




相关问题
Borland Assertion failed in local_unwind()

I have a comms server that is supposed to run for an indefinite amount of time. However, it sometimes errors with Assertion failed: !"bogus context in Local_unwind()", file xx.cpp, line 2262 ...

Install a .bpk into Borland C++ Builder from the command line

I am attempting to install a .bpk package into the Borland C++ Builder 5 IDE from the command line. I am sure that this is possible, as we have some third party components that manage to do so, but I ...

How can I add libCurl to a Borland C++ Builder 6 Project?

How can I add libCurl to a Borland C++ Builder 6 Project? I tried including its directory in the project s compiler and linker search paths, then I made a lib from the libcurl dll and I added it to ...

热门标签