fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. int main(){
  5. int** arr = NULL;
  6. int n;
  7. printf("input n: ");
  8. scanf("%d", &n);
  9. int * sum = calloc(n,sizeof(int));
  10.  
  11. arr = (int**)malloc(sizeof(int*) * n);
  12. for(int i = 0; i < n; i++)
  13. {
  14. arr[i] = (int*)malloc(sizeof(int) * n);
  15. }
  16.  
  17. srand(time(NULL));
  18. for(int i = 0; i < n; i++)
  19. {
  20. for(int j = 0; j < n; j++)
  21. {
  22. arr[i][j] = rand() % 51;
  23. printf("%d\t", arr[i][j]);
  24. }
  25. printf("\n");
  26. }
  27. for(int j = 0; j < n; j++)
  28. for(int i = 0; i < n; i++)
  29. sum[j] += arr[i][j];
  30.  
  31. for(int j= 0; j < n; j++)
  32. printf("summa %d stolbtsa =%d\n", j+1, sum[j]);
  33. free(arr);
  34. free(sum);
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0s 4500KB
stdin
6
stdout
input n: 45	26	42	48	5	11	
33	29	14	25	44	10	
8	45	4	45	44	13	
22	38	15	30	44	26	
47	36	9	9	24	6	
44	43	32	10	14	11	
summa 1 stolbtsa =199
summa 2 stolbtsa =217
summa 3 stolbtsa =116
summa 4 stolbtsa =167
summa 5 stolbtsa =175
summa 6 stolbtsa =77