Clasified in Exams of Information technology of University.
Written at February 11, 2009 on
Español, translated to
English and with a size of 3,005 bytes.
SPEND DATA MATRIX TO ANOTHER
# include
# include
main ()
(
int a [64] [4];
int b [3] [15], i, region, sumasup, sumahab, j;
j = 0;
region = 1;
for (i = 0, i <65-1; i + +)
(
if (a [i] [0] = region)
(
sumasup = sumasup + a [i] [2];
sumahab = sumahab + a [i] [3];
)
if (a [i +1] [0]! = region)
(
b [0] [j] = region;
b [1] [j] = sumasup;
b [2] [j] = sumahab;
j + +;
sumasup = 0;
sumahab = 0;
region + +;
)
)
if (a [i] [0] = region)
sumasup = sumasup + a [i] [2];
Sumahan suamahab + = a [i] [3];
)
/ / Write a C language program that prompts the user to enter
/ / 9 numbers, these numbers were stored in a matrix of 3x3. The numbers in
/ / position pair and join detract odd position. To calculate whether the
/ / number is odd or even position is used the sum of the 2 subscripts
/ / 0 is considered as a pair.
# include
# include
# define f 3
# define c 3
main ()
(
int a [f] [c];
int num, result = 0, i, j;
for (i = 0; i (
for (j = 0, j (
printf ( "Enter number:");
scanf ( "% d", & num);
a [i] [j] = num;
if ((i + j)% 2 == 0)
result = result + num;
else
result = result-num;
)
)
printf ( "Result is% d", result);
getch ();
)
/ / Write a C language program that prompts the user to enter 16 numbers
/ / which correspond to a 4x4 matrix, are asked to calculate the sum of:
/ / a. Main diagonal.
/ / b. Secondary Diagonal.
/ / c. The first and last row.
/ / d. The first and last column.
# include
# include
int main (void)
(
int matr [4] [4] suma_dp = 0, suma_ds = 0, suma_pu_f = 0, suma_pu_c = 0;
for (int i = 0, i <4; i + +)
(
for (int j = 0 j <4; j + +)
(
printf ( "Enter number [% i] [% i]:", i, j);
scanf ( "% i", & matr [i] [j]);
)
)
for (int l = 0, l <4; l + +)
(
suma_dp + = matr [l] [l];
suma_ds + = matr [l] [3-l];
suma_pu_f + = matr [0] [l];
suma_pu_f + = matr [3] [l];
suma_pu_c + = matr [l] [0];
suma_pu_c + = matr [l] [3];
)
printf ( "The sum of the main diagonal:% i", suma_dp);
printf ( "The sum of the secondary diagonal:% i", suma_ds);
printf ( "The sum of the first and last row:% i", suma_pu_f);
printf ( "The sum of the first and last column:% i", suma_pu_c);
system ( "pause");
)
| Tags:ELEMENTS,passing data from one array to another,includemain,sumahab,include,sumasup | |
| This document has been visited 12,531 times and has received 14 votes | |
| Others users that have visited this document also searched for: | |
rev of number in c languagesuma matrices lenguaje csecondary diagonal c++c language reviewstalf ejercicios resueltossum of odd position in c languageC language reviewmatrix lenguaje cejercicios resueltos talfsuma de matrices en creview of c language | |