Skip to content

Instantly share code, notes, and snippets.

@henryyang42
Created May 20, 2017 06:05
Show Gist options
  • Select an option

  • Save henryyang42/57a6464fa3b952d33cd30e2a4c1bc8eb to your computer and use it in GitHub Desktop.

Select an option

Save henryyang42/57a6464fa3b952d33cd30e2a4c1bc8eb to your computer and use it in GitHub Desktop.
#include <stdio.h>
#define MAX_N 10
#define MAX_M 10
void add_one(int s[MAX_N][MAX_M], int n, int m) {
/* All elements in s will add one. */
int i, j;
for(i = 0; i < n; i++)
for(j = 0; j < m; j++)
s[i][j] += 1;
}
int main() {
int leo87[MAX_N][MAX_M] = {}; /* Initial all 0*/
int n = 8, m = 7;
add_one(leo87, n, m); /* Only add one to 8x7 */
int i, j;
for(i = 0; i < MAX_N; i++, putchar(10))
for(j = 0; j < MAX_N; j++)
printf("%d ", leo87[i][j]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment