使用Borland 32位的C ++源代码 [英] C++ source code using Borland 32 bits

查看:52
本文介绍了使用Borland 32位的C ++源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用7 os 64位窗口
Borland编译器32位
编译0警告0错误,但在尝试运行代码时失败,您能帮忙吗


只需要一些指导,如前所述,也许我的格式很丑
只需要知道我如何才能运行此代码,缩短程序并获得相同的结果


I am using window 7 os 64 bits
a boreland compiler 32 bit
compile 0 warning 0 errors but make fail when i try to run code, can youu help


just need some guidance, as earlier suggested maybe my format is ugly
just need to know how i can get to run this code , shorten the program and have the same result


int main()
{
    // start of main

//Main_menu();

}//end of main
void Main_menu(void)
{
    char choice;
    do
    {
        printf("\tA. Populate the matrix\n");
        printf("\tB. Display the matrix\n");
        printf("\tC. Perform operation\n");
        printf("\tD. Credits\n");
        printf("\tE. Exit Program\n\n\n");
        printf("Please enter your choice: ");
        scanf(" %c",&choice);
        choice = toupper(choice);
//system("cls");

        switch(choice)
        {
        case 'A':
        {
            Populate_Matrix();
            break;
        }
        case 'B':
        {
            display();
            break;
        }
        case 'C':
        {
            operations();
            break;
        }
        case 'D':
        {
            printf("\n Dr. T. Chambers C++ group  2011\n\n\n\n");
            break;
        }
        case 'E':
        {
            break;
        }
        default:
        {
            printf("Please choose a letter from A-E,You enterd a letter that is not accepted\n");
        }
        }
    }
    while(choice !=0);
}
void Populate_Matrix(void)
{
    int i,j;
    do
    {
        printf("Enter the number of matrix you need\n");
        scanf("%d",&size);
    }
    while(size <0 || size >5);
    printf("Enter the number of row and colums of mantrix\n");
    scanf("%d%d",&rows,&columns);
    if(size > 0 && size <= 5 )
    {
        printf("\tA. Add values to matrix A\n");
        for(i=0; i < rows; i++)
        {
            for(j=0; j < columns; j++)
            {
                scanf("%d",&arrayA[i][j]);
            }
        }
    }
    if(size>1 && size <=5)
    {
        printf("\tA. Add values to matrix B\n");
        for(i=0; i < rows; i++)
        {
            for(j=0; j < columns; j++)
            {
                scanf("%d",&arrayB[i][j]);
            }
        }
    }
    if(size>2 && size <=5)
    {
        printf("\tA. Add values to matrix C\n");
        for(i=0; i < rows; i++)
        {
            for(j=0; j < columns; j++)
            {
                scanf("%d",&arrayC[i][j]);
            }
        }
    }
}

void display(void)
{
    int i, j;
    if(size > 0 && size <= 5 )
    {
        printf("\t Add values to matrix A\n");
        for(i=0; i < rows; i++)
        {
            for(j=0; j < columns; j++)
            {
                printf("%d ",arrayA[i][j]);
            }
            printf("\n");
        }
    }
    printf("\n");
    if(size>1 && size <=5)
    {
        printf("\t values to matrix B\n");
        for(i=0; i < rows; i++)
        {
            for(j=0; j < columns; j++)
            {
                printf("%d ",arrayB[i][j]);
            }
            printf("\n");
        }
    }
    printf("\n");
    if(size>2 && size <=5)
    {
        printf("\tValues stores matrix C\n");
        for(i=0; i < rows; i++)
        {
            for(j=0; j < columns; j++)
            {
                printf("%d ",arrayC[i][j]);
            }
            printf("\n");
        }
    }
    printf("\n");
}

void operations()
{
    int choice=0;
    do
    {
        printf("\t1 Scalar\n");
        printf("\t2 Addition\n");
        printf("\t3 Substraction\n");
        printf("\t4 Multiplication\n");
        printf("\t5 Exit Program\n\n\n");
        scanf(" %d",&choice);
        switch(choice)
        {
        case 1:
            ScalarMult();
            break;
        case 2:
            addition();
            break;
        case 3:
            subtraction();
            break;
        case 4:
            multiplication();
            break;
        default:
        {
            printf("Please choose a letter from A-E,You enterd a letter that is not accepted\n");
        }
        }
    }
    while(choice !=0);
}

void addition()
{
    int i,j;
    int result[5][5]= {0};
    int choice1, choice2;
    printf("Enter the two matrix you need to use\n");
    scanf("%d %d", &choice1,&choice2);
    if(choice1 == 1 && choice2 ==2)
    {
        for(i=0; i < rows; i++)
        {
            for(j=0; j < columns; j++)
            {
                printf("%d ",result[i][j] = arrayA[i][j] + arrayB[i][j]);
            }
            printf("\n");
        }
    }
    if(choice1 == 1 && choice2 ==3)
    {
        for(i=0; i < rows; i++)
        {
            for(j=0; j < columns; j++)
            {
                printf("%d ",result[i][j] = arrayA[i][j] + arrayC[i][j]);
            }
            printf("\n");
        }
    }
    if(choice1 == 2 && choice2 ==3)
    {
        for(i=0; i < rows; i++)
        {
            for(j=0; j < columns; j++)
            {
                result[i][j] = arrayC[i][j] + arrayB[i][j];
            }
        }
    }
}

void subtraction()
{
    int i,j;
    int result[5][5]= {0};
    int choice1, choice2;
    printf("Enter the two matrix you need to use\n");
    scanf("%d %d", &choice1,&choice2);
    if(choice1 == 1 && choice2 ==2)
    {
        for(i=0; i < rows; i++)
        {
            for(j=0; j < columns; j++)
            {
                printf("%d ",result[i][j] = arrayA[i][j] - arrayB[i][j]);
            }
            printf("\n");
        }
    }
    if(choice1 == 1 && choice2 ==3)
    {
        for(i=0; i < rows; i++)
        {
            for(j=0; j < columns; j++)
            {
                printf("%d ",result[i][j] = arrayA[i][j] - arrayC[i][j]);
            }
            printf("\n");
        }
    }
    if(choice1 == 2 && choice2 ==3)
    {
        for(i=0; i < rows; i++)
        {
            for(j=0; j < columns; j++)
            {
                result[i][j] = arrayC[i][j] - arrayB[i][j];
            }
        }
    }

}

void ScalarMult()
{
    int i,j;
    int result[5][5]= {0};
    int choice1, scaleFactor;
    printf("Enter the two matrix you need to SCALE and scale factor\n");
    scanf("%d %d", &choice1,&scaleFactor);
    if(choice1 == 1 )
    {
        for(i=0; i < rows; i++)
        {
            for(j=0; j < columns; j++)
            {
                printf("%d ",arrayA[i][j] * scaleFactor);
            }
            printf("\n");
        }
    }
    if(choice1 == 2 )
    {
        for(i=0; i < rows; i++)
        {
            for(j=0; j < columns; j++)
            {
                printf("%d ",arrayB[i][j] * scaleFactor);
            }
            printf("\n");
        }
    }
    if(choice1 == 3)
    {
        for(i=0; i < rows; i++)
        {
            for(j=0; j < columns; j++)
            {
                printf("%d ",arrayC[i][j] * scaleFactor);
            }
        }
    }
}

void multiplication()
const int _M1ROWS = 2;
const int _M1COLS = 3;
const int _M2ROWS = 3;
const int _M2COLS = 2;

int main()



[格式编辑]

[edit]添加了< pre>标签周围的代码,以便于阅读! RJM [/edit]



[edited for formatting]

[edit]Added <pre> tags around code so it is readable! RJM[/edit]

推荐答案

编译0警告0错误,但在尝试运行代码时失败,您能帮忙吗?"

编号

为什么不?有两个原因:
1)您没有告诉我们问题是什么,应该做什么或做错了什么.
2)我没有看那个代码!如果您想读取代码,请对其进行格式化,以使我们易于阅读.
您想尝试哪种方法:
"compile 0 warning 0 errors but make fail when i try to run code, can youu help"

No.

Why not? For two reasons:
1) You don''t tell us what the problem is, what it is supposed to do, or what it is doing wrong.
2) I am not reading that code! If you want code to be read, then format it to make it easy for us to read.
Which would you rather try to work out:
if(size>2 && size <=5)
{
printf("\tValues stores matrix C\n");
for(i=0; i < rows; i++)
{
for(j=0;j < columns; j++)
{
printf("%d ",arrayC[i][j]);
}
printf("\n");
}
}


if(size>2 && size <=5)
   {
   printf("\tValues stores matrix C\n");
   for(i=0; i < rows; i++)
      {
      for(j=0;j < columns; j++)
         {
         printf("%d ",arrayC[i][j]);
         }
      printf("\n");
      }
   }


这篇关于使用Borland 32位的C ++源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆