Generation

generate functionTue, 23 May 2023

#include <stdio.h> int nrow; int ncol; int checkcolumn(int **xy) { int ret; for (int i = 0; i < nrow; i++) { for (int k = 0; k < ncol; k++) { for (int j = 0; j < ncol+1; j++) { if (j != ncol+1) { if (xy[k][i] > xy[k][5-j]) { continue; } else { break; } } if (j == ncol+1) { ret = xy[k][i]; } } } } return ret; } int main() { int m[3][3] = { {3, 5, 7}, {2, 9, 10}, {4, 6, 8} }; ncol = sizeof(m[0]) / sizeof(m[0][0]); nrow = sizeof(m) / sizeof(m[0]); printf("%d \n", checkcolumn((int **)m)); printf("fin"); } int checkrow(int *xy[]) { int ret; for (int i = 0; i < ncol; i++) { for (int k = 0; k < nrow; k++) { for (int j = 0; j < nrow+1; j++) { if (j != nrow+1) { if (xy[i][k] > xy[i][5-j]) { continue; } else { break; } } if (j == nrow+1) { ret = xy[i][k]; } } } } return ret; }

function that: given a number, n, return the sum of the first n numbers

Questions about programming?Chat with your personal AI assistant