- 分享
- 0
- 人气
- 0
- 主题
- 55
- 帖子
- 28467
- UID
- 13196
- 积分
- 2027
- 阅读权限
- 20
- 注册时间
- 2005-5-7
- 最后登录
- 2024-10-20
- 在线时间
- 27267 小时
|
Question1: Matrix operations using array and function.
Write a complete C program to perform Matrix operations such as Addition, Subtraction, Multiplication and Transpose according to the user’s choice. Define functions to perform these various operations and call them from the main function whenever needed. The program should display the following menu to the user for them to select one of the five options listed.
------------------
MAIN MENU
------------------
1.MATRIX ADDITION
2.MATRIX SUBTRACTION
3.MATRIX MLTIPLICATION
4.MATRIX TRANSPOSE
5.TO EXIT
---------------------------
Please enter your option <1/2/3/4/5>:
The program should ask the elements of the input matrix or matrices from the user once the required operation is selected and also should check whether the required operation can be carried out or not based on the input data. The program should produce a neat output showing both the input and the resultant matrix in matrix form. The program should not be terminated until the user selects the option number 5 (TO EXIT).
我到这里就不会了:
#include "stdafx.h"
#include <stdio.h>
int main()
{
int add,sub,mul,tran,opt;
printf("---------\n");
printf("MAIN MENU\n");
printf("---------\n");
printf("1-MATRIX ADDITION\n");
printf("2-MATRIX SUBTRACTION\n");
printf("3-MATRIX MULTIPLICATION\n");
printf("4-MATRIX TRANPOSE\n");
printf("5-EXIT\n");
printf("-------------------\n");
printf("Please enter your option <1/2/3/4/5>:\n");
scanf("%d",&opt);
switch(opt);
{
case 1:这里开始完全不懂怎样写!
while(opt == 5);
{
printf("---------\n");
printf("MAIN MENU\n");
printf("---------\n");
printf("1-MATRIX ADDITION\n");
printf("2-MATRIX SUBTRACTION\n");
printf("3-MATRIX MULTIPLICATION\n");
printf("4-MATRIX TRANPOSE\n");
printf("5-EXIT\n");
printf("-------------------\n");
printf("Please enter your option <1/2/3/4/5>:\n");
scanf("%d",&opt);
}
}
p/s:应该是C不是C++,谢谢三楼大大的提醒!
[ 本帖最后由 aiklone1314 于 2009-9-7 10:09 AM 编辑 ] |
|