-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe9.c
42 lines (34 loc) · 809 Bytes
/
e9.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
void copy(int, int, const double source[*][*], double dest[*][*]);
void show(int, int, const double a[*][*]);
int main(void)
{
const double s[3][5] = {
{1., 2., 3., 4., 5.},
{6., 7., 8., 9., 10.},
{11., 12., 13., 14., 15.}
};
double d[3][5];
copy(3, 5, s, d);
show(3, 5, d);
return 0;
}
void copy(int rows, int cols, const double source[rows][cols], double dest[rows][cols])
{
for(int i = 0; i < rows; i++ )
{
for ( int c = 0; c < cols; c++ )
{
dest[i][c] = source[i][c];
}
}
}
void show(int rows, int cols, const double a[rows][cols])
{
for(int i = 0; i < rows; i++ )
{
for ( int c = 0; c < cols; c++ )
printf("%lf ", a[i][c]);
printf("\n");
}
}