0

c question, what is the problem ?

#include <stdio.h> #include <conio.h> #include <stdlib.h> #include <time.h> int main() { int x[10][10],y[10][10],sum[10][10],c,d,i,j; for(c=0;c,10;c++) { for(d=1;d=10;d++) { for(i=0;i=10;i++) { j=rand()%100+1; x[c][d]=j; printf("%d ",j); } } printf("\n"); } system("cls"); for(c=0;c,10;c++) { for(d=1;d=10;d++) { for(i=0;i=10;i++) { j=rand()%100+1; y[c][d]=j; printf("%d ",j); } } printf("\n"); } system("cls"); printf("sum of entered matrices:\n"); for(c=0;c,10;c++) { for(d=1;d=10;d++) { sum[c][d]=x[c][d]+y[c][d]; printf("%d ",sum[c][d]); } printf("\n"); } getch(); return 0; }

16th Dec 2018, 7:05 PM
Fatemeh Rahimzadeh
Fatemeh Rahimzadeh - avatar
3 ответов
+ 2
#include <stdio.h> #include <stdlib.h> #include <time.h> int main() { srand((size_t)time(NULL)); int x[10][10], y[10][10], sum[10][10], c, d, i, j; printf("Mat X:\n"); for (c = 0; c < 10; c++) { for (i = 0; i < 10; i++) { j = rand() % 100 + 1; x[c][i] = j; printf("%-3d ", j); } printf("\n"); } printf("\nMat Y:\n"); for (c = 0; c < 10; c++) { for (i = 0; i < 10; i++) { j = rand() % 100 + 1; y[c][i] = j; printf("%-3d ", j); } printf("\n"); } printf("\nsum of entered matrices:\n"); for (c = 0; c < 10; c++) { for (d = 1; d < 10; d++) { sum[c][d] = x[c][d] + y[c][d]; printf("%-3d ", sum[c][d]); } printf("\n"); } return 0; }
16th Dec 2018, 7:26 PM
Babak
Babak - avatar
+ 2
Sample output: Mat X: 72 85 91 50 8 22 51 20 10 72 39 51 61 2 73 8 64 71 84 17 85 42 70 56 10 15 99 56 20 96 51 44 32 93 93 39 15 95 11 76 66 49 78 79 2 2 38 18 73 21 86 9 14 55 17 75 21 15 83 93 62 33 36 93 25 80 32 91 26 94 66 43 42 44 21 96 45 58 13 69 31 98 30 96 53 46 71 25 12 53 17 74 37 4 66 13 83 49 4 8 Mat Y: 42 21 3 36 64 23 31 61 33 95 29 63 92 10 58 96 55 80 21 67 84 89 92 20 93 57 85 75 58 88 35 51 8 37 86 24 11 68 36 43 62 64 5 6 74 15 1 80 94 73 98 78 62 89 49 54 98 33 80 7 72 66 57 32 2 95 7 13 62 42 7 76 57 64 81 82 78 33 62 23 6 11 52 19 100 53 24 49 85 3 55 9 69 11 40 22 5 98 86 19 sum of entered matrices: 106 94 86 72 45 82 81 43 167 114 153 12 131 104 119 151 105 84 131 162 76 103 72 184 131 78 184 95 40 130 179 63 26 163 47 119 113 83 85 76 17 39 98 167 94 87 76 144 66 129 119 48 163 100 99 93 125 27 175 39 104 88 136 119 99 108 102 178 123 91 75 92 109 82 115 153 99 95 74 97 56 83 106 15 106 35 88 147 90 27
16th Dec 2018, 7:26 PM
Babak
Babak - avatar
0
thanks
16th Dec 2018, 7:36 PM
Fatemeh Rahimzadeh
Fatemeh Rahimzadeh - avatar