Skip to content

Instantly share code, notes, and snippets.

@th0j
Last active October 4, 2018 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save th0j/52895364a69ab4de12a2413c80dae8bb to your computer and use it in GitHub Desktop.
Save th0j/52895364a69ab4de12a2413c80dae8bb to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
int main() {
int n = 3;
int m = 3;
int a[3][3] = { 0 };
a[1][1] = 5;
int x = 5;
int b[10] = { 1, 3, 5, 7, 9, 2, 4, 6, 8 };
int k = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
if (b[k] == x) {
k++;
}
if (a[i][j] == 0) {
a[i][j] = b[k];
} else {
continue;
}
k++;
}
}
printf("\n");
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
printf("%d", a[i][j]);
}
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment