convert c++ code to c online
#include <stdio.h>
#include <math.h>
#define COLUMN 6
void createPattern(char pattern[][COLUMN],int numStudent,int row) {
for(int i = 0; i < row ; i++) {
for(int j = 0; j < COLUMN; j++) {
if(numStudent!=0) {
pattern[i][j] = 'X';
numStudent -- ;
}
else if(numStudent==0) {
pattern[i][j] = ' ';
}
}
}
}
void bookSeat(char pattern[][COLUMN],int rowB,int columnB) {
if(pattern[rowB-1][columnB-1] != ' ') {
pattern[rowB-1][columnB-1] = 'S';
}
}
void printPattern(char pattern[][COLUMN],int row) {
for(int i = 0; i < row ; i++) {
for(int j = 0; j < COLUMN; j++) {
printf("%c",pattern[i][j]);
if(j < COLUMN-1) {
printf(" ");
}
}
printf("\n");
}
}
int main() {
int numStudent,numSeat;
scanf("%d",&numStudent);
if(numStudent>=1 && numStudent<=40) {
int rowBook,columnBook;
int row = ceil((double)numStudent/COLUMN);
char pattern[row][COLUMN];
createPattern(pattern,numStudent,row);
scanf("%d",&numSeat);
for(int i = 0 ; i < numSeat ; i++) {
scanf("%d %d",&rowBook,&columnBook);
if((rowBook >= 1 && rowBook <= row ) && (columnBook >= 1 && columnBook <= COLUMN)) {
bookSeat(pattern,rowBook,columnBook);
}
}
printPattern(pattern,row);
}
else if(numStudent<1) {
printf("Students not enough.\n");
}
else if(numStudent>40) {
printf("Too many students.\n");
}
return 0;
}