代做C语言程序,学校的补考,后天交,再不过就完了,Question 1 - 15 marksWrite a C program that prints out all di\x0berent possibilities of obtaining $2(2pounds) using coins of values 2 pence,5 pence,and 10 pence.Indicate howmany possibi

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/17 07:53:02

代做C语言程序,学校的补考,后天交,再不过就完了,Question 1 - 15 marksWrite a C program that prints out all di\x0berent possibilities of obtaining $2(2pounds) using coins of values 2 pence,5 pence,and 10 pence.Indicate howmany possibi
代做C语言程序,学校的补考,后天交,再不过就完了,
Question 1 - 15 marks
Write a C program that prints out all di\x0berent possibilities of obtaining $2(2
pounds) using coins of values 2 pence,5 pence,and 10 pence.Indicate how
many possibilities have been found.The output of your program may look like:
$2 = 100 x 2p
$2 = 90 x 2p + 4 x 5p
$2 = 80 x 2p + 8 x 5p .
In total,there are possibilities to make $2.
Note that (no.of the possibilities) is calculated by your C program.
Question 2 - 15 marks
Write a C program that reads m x n matrix "A" and p x q matrix "B",checks
whether these matrices are multipliable in either order or not (e.g.whether A
x B or B x A is de\x0cned).Further,if A x B or B x A is de\x0cned then calculates
the product and prints out the result.
Question 3 - 20 marks
Write a C program that initializes an array of integer and then copies the con-
tents of the array into two other arrays.Declare all arrays in the main program.
To make the \x0crst copy,write a function,which uses the array notation (the
square brackets []) to access the elements of the array.
To make the second copy,write a function that uses the pointer notation and
pointer incrementing to access the elements of the arrays.
Each function takes the name of the source array,the name of the target/destination
1
array and the number of elements to be copied as function arguments.
Here is an example showing how the functions should be called giving the fol-
lowing declarations:
int source[4] = {1,2,4,6};
int destination1[4];
int destination2[4];
copy_array(source,destination1,4);
copy_ptr(source,destination2,4);
Question 4 - 50 marks
A ferry has a seating capacity of 30 arranged as 10 rows (1 to 10) of three seats:
A,B and C (i.e.the seat identi\x0ccation labels are 1A,1B,1C,...).It makes one
trip a day.Write a seating reservation program in C with the following features:
1.The program uses an array of 30 structures.Each structure should hold a
seat identi\x0ccation label,a
ag that indicates whether the seat is assigned,
the last name of the seat holder (max 30 characters),the \x0crst name of
the seat holder (max 30 characters),and the price of the seat (the price
arrangement is up to your choice).
2.The program displays the following menu:
To choose a function,enter its letter label -
\x0f (a) Show assigned seats with passenger names.
\x0f (b) Show list of the cheapest seats available.
\x0f (c) Show list of the most expensive seats booked.
\x0f (d) Assign a customer to a seat.
\x0f (e) Edit customer details,for a speci\x0cc seat.
\x0f (f) Delete a seat assignment.
\x0f (g) Quit.
After executing a particular function the program should show the menu again
except for choice (g).
Hints:The program might save the data in a \x0cle between runs and load the
data (if any) at the start of the program.

代做C语言程序,学校的补考,后天交,再不过就完了,Question 1 - 15 marksWrite a C program that prints out all di\x0berent possibilities of obtaining $2(2pounds) using coins of values 2 pence,5 pence,and 10 pence.Indicate howmany possibi
////////////////////////////////第一题
/*
Question 1 - 15 marks
Write a C program that prints out all di\x0berent possibilities of obtaining $2(2
pounds) using coins of values 2 pence, 5 pence, and 10 pence. Indicate how
many possibilities have been found. The output of your program may look like:
$2 = 100 x 2p
$2 = 90 x 2p + 4 x 5p
$2 = 80 x 2p + 8 x 5p .
In total, there are ? possibilities to make $2.
Note that ? (no. of the possibilities) is calculated by your C program.
*/
#include
void main()
{
int count2,count5,count10;
int count=0;
int sum;
count=0;
for( count2=100; count2>=0 ; count2=count2-1 )
for( count5=40; count5>=0; count5=count5-1 )
for( count10=20; count10>=0; count10=count10-1 )
{
sum=count2*2 + count5*5 + count10*10;
if( sum==200 )
{
printf("$2 =");
if( count2!=0 )
printf(" +%d X 2p",count2);
if( count5!=0 )
printf(" +%d X 5p",count5);
if( count10!=0 )
printf(" +%d X 10p",count10);
printf("\n");
count++;
}
}
printf("In total, there are %d possibilities to make $2.\n",count);
}
///////////////////////////////////////////第二题
/*
Question 2 - 15 marks
Write a C program that reads m x n matrix "A" and p x q matrix "B", checks
whether these matrices are multipliable in either order or not (e.g. whether A
x B or B x A is de\x0cned). Further, if A x B or B x A is de\x0cned then calculates
the product and prints out the result.
*/
/* 矩阵元素是整型的 */
#include
#define MAX 256
void SetZero( int a[MAX][MAX] );
void Print( int a[MAX][MAX], int r, int c );
void MultiplyMatrix( int a[MAX][MAX],int m,int n, int b[MAX][MAX],int p, int q );
int result[MAX][MAX];//存放结果
/* 矩阵相乘 */
void MultiplyMatrix( int a[MAX][MAX],int m,int n, int b[MAX][MAX],int p, int q )
{
int row,column;
SetZero(result);
if( n==p )
{
for( row=0; row