Пример #1
0
int main(void) {
    int n, Sum;
    char AddChoice;
    printf("1+2+...+n=?請輸入n=");
    scanf("%d", &n);
    fflush(stdin);
    printf("請問要做奇數和(O),偶數和(E),還是整數和(I)?請選擇:");
    scanf("%c", &AddChoice);

    switch (AddChoice) {
    case 'O':
        Sum = Odd(n);
        break;

    case 'E':
        Sum = Even(n);
        break;

    case 'I':
        Sum = TotalSum(n);
        break;

    default:
        printf("選擇錯誤\n");
        return -1;
    }

    printf("總和為%d\n", Sum);
    /*  system("pause");  */
}
/*******************************************************************
 * Function Name: Print_ConfusionMat
 * Return Type 	: int
 * Created On	: Jul 8, 2013
 * Created By 	: hrushi
 * Comments		: Print the Confusion Matrix
 * Arguments	:
 *******************************************************************/
int GroundTruth::Print_ConfusionMat( const Args& args ) const
{
	cout << "Confusion Matrix is : "  <<  endl;
	cout << "     *****" << " Predicted " << "*****" << endl;
	for( UINT i = 0; i < GND_CATEGORIES; i++ )
	{
		cout << m_RowHeader.at(i) << "\t";


		UINT Row_Sum(0);

		for( UINT j = 0; j < GND_CATEGORIES; j++ )
		{
			cout << std::setw(4) << m_ConfusionMat[i][j] << " & ";

			Row_Sum += m_ConfusionMat[i][j];

			if( j == (GND_CATEGORIES - 1) )
			{
				cout << std::setw(4) << Row_Sum;
			}
		}

		cout << endl;
	}

	cout << endl;

	UINT TotalSum(0);

	cout << "Total \t";
	for( UINT j = 0; j < GND_CATEGORIES; j++ )
	{
		UINT Col_Sum(0);

		for( UINT i = 0; i < GND_CATEGORIES; i++ )
		{
			Col_Sum += m_ConfusionMat[i][j];
			TotalSum += m_ConfusionMat[i][j];
		}

		cout << std::setw(4) << Col_Sum << " & ";

		if( j == (GND_CATEGORIES - 1) )
		{
			cout << std::setw(4) << TotalSum;
		}
	}

	cout << endl;

	PrintStats( args );

	return EXIT_SUCCESS;
}