#!/bin/ch /* Web Matrix Calculator source code written in CH/C */ /* History: created by Harry H. Cheng, 2/8/1996 */ /* Last modified: 2/22/96 */ #include void sendMatrixApplet(int numMatrix, int RowA, int ColA, int RowB, int ColB, double A[:][:], double B[:][:], char *expr) { int i, j; class CResponse Response; Response.setContentType("application/x-chs"); Response.begin(); printf("#include\n"); printf("#include\n"); printf("int main() {\n"); printf("array double A[%d][%d];\n",RowA, ColA); printf("array double B[%d][%d];\n",RowB, ColB); for(i=0;iWeb Matrix Calculator Failed\n"); printf("\n"); printf("

Web Matrix Calculator Failed

\n"); printf("Your mathematical expression has not been submitted to Matrix Calculator,\n"); printf("because %s. ",reason); printf("Try again.\n"); printf("


\n"); printf("\n"); printf("\"Powered\n"); exit(1); } int main() { chstrarray name, value; int num, i, j , k, rowA=1, colA=1, rowB=1, colB=1, numMatrix=1; string_t reason; class CRequest Request; num = Request.getFormNameValue(name, value); if(num==0) errorHandler("you submitted nothing"); if(!value[num-1]) errorHandler ("you didn't input a matrix expression"); numMatrix = atoi(value[0]); if(numMatrix == 1) { rowA = atoi(value[1]); colA = atoi(value[2]); k = 3; } else if(numMatrix == 2) { rowA = atoi(value[1]); colA = atoi(value[2]); rowB = atoi(value[3]); colB = atoi(value[4]); numMatrix=2; k = 5; } else { sprintf(reason,"%d is not a valid number of matrices", atoi(value[0])); errorHandler(reason); } double A[rowA][colA]; /* variable length array */ double B[rowB][colB]; for(i=0;i