关于C语言的一道试题求助高手
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/11 10:59:24
关于C语言的一道试题求助高手
Question 1 - 20 marks
Write a C program that prints out all of the different ways of obtaining 1 (1 pound) using coins of values 1
pence,2 pence,5 pence.Indicate how many possibilities have been found.The output of your program
should look like:
1 = 100 x 1p
1 = 90 x 1p + 5 x 2p
1 = 80 x 1p + 5 x 2p+2x5p.
Your C program should also calculate the number of possible ways of making 1 using the available coins.
Question 2 - 30 marks
Write a C function using pointer(s) called PFunc that take as input an m x n matrix “A” and an n x q matrix
“B” as well as a C program to test this function.Your program should:
1.
represent the matrices as two two-dimensional arrays
2.
allow the user to specify the size of array A and B,i.e.,m,n,q at execution time
3.
use malloc to allocate memory space for the array
4.
calculate and display the resulting matrix AxB
5.
check in your function if AxB is a symmetric matrix and also display this information
6.
your function should calculate and display the largest value in the array (AxB).
You should design your own input and output format for this program.
Question 3 - 50 marks
A ferry has a seating capacity of 30 arranged in 10 rows (1 to 10) of three seats:A,B and C (i.e.the seat
identification labels are 1A,1B,1C,etc.).The ferry makes one trip a day.Write a seating reservation
program for the ferry in C with the following features:
Question 1 - 20 marks
Write a C program that prints out all of the different ways of obtaining 1 (1 pound) using coins of values 1
pence,2 pence,5 pence.Indicate how many possibilities have been found.The output of your program
should look like:
1 = 100 x 1p
1 = 90 x 1p + 5 x 2p
1 = 80 x 1p + 5 x 2p+2x5p.
Your C program should also calculate the number of possible ways of making 1 using the available coins.
Question 2 - 30 marks
Write a C function using pointer(s) called PFunc that take as input an m x n matrix “A” and an n x q matrix
“B” as well as a C program to test this function.Your program should:
1.
represent the matrices as two two-dimensional arrays
2.
allow the user to specify the size of array A and B,i.e.,m,n,q at execution time
3.
use malloc to allocate memory space for the array
4.
calculate and display the resulting matrix AxB
5.
check in your function if AxB is a symmetric matrix and also display this information
6.
your function should calculate and display the largest value in the array (AxB).
You should design your own input and output format for this program.
Question 3 - 50 marks
A ferry has a seating capacity of 30 arranged in 10 rows (1 to 10) of three seats:A,B and C (i.e.the seat
identification labels are 1A,1B,1C,etc.).The ferry makes one trip a day.Write a seating reservation
program for the ferry in C with the following features:
题目太多.
第一题简单.用循环语句加判断就可以了.
给你第2题答案.命令行 带 3 个参数,例如 a.exe 3 2 3
#include
#include
#define DEBUG 1
void PFunc(int *a,int *b,int a_row,int a_col,int b_col)
{
int i,j,b_row;
static int tmp;
b_row = a_col;
printf("Please input int matrix a[%d][%d] 1 2 3 4 5 6\n",a_row,a_col);
for (j=0;j
第一题简单.用循环语句加判断就可以了.
给你第2题答案.命令行 带 3 个参数,例如 a.exe 3 2 3
#include
#include
#define DEBUG 1
void PFunc(int *a,int *b,int a_row,int a_col,int b_col)
{
int i,j,b_row;
static int tmp;
b_row = a_col;
printf("Please input int matrix a[%d][%d] 1 2 3 4 5 6\n",a_row,a_col);
for (j=0;j