Skip to content

Instantly share code, notes, and snippets.

@PaulChristmas
Created May 15, 2016 12:28
Show Gist options
  • Save PaulChristmas/3ad9ef785352fc94e6d07e4224f6664a to your computer and use it in GitHub Desktop.
Save PaulChristmas/3ad9ef785352fc94e6d07e4224f6664a to your computer and use it in GitHub Desktop.
#include <stdio.h>
const m = 6;
const n = 8;
int main (void) {
int i, j, count = 0;
double A[m][n], B[m * n];
for (i = 0; i < m; i++){
for (j = 0; j < n; j++){
printf ("\nA[%d][%d] = ", i, j);
scanf("%lf", &A[i][j]);
}
}
for (j = 0; j < n; j++){
for (i = 0; i < m; i++){
if (A[i][j] < 0){
B[count] = A[i][j];
count++;
}
}
}
printf ("%d elements found ", count);
if (count > 0){
printf("B = [");
for (i = 0; i < count - 1; i++){
printf("%lf, ", B[i]);
}
printf("%lf]", B[count - 1]);
}
getch();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment