Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- */
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
- #define M 9
- #define N 7
- int plegma[9][9];
- void eisagwgi() {
- int i,j,akeraioi;
- for (i=0; i<M; i++) {
- for (j=0; j<M; j++) {
- scanf("%d ", &akeraioi); /*whitespace stin arxi keno i meta??*/
- plegma[i][j]=akeraioi;
- }
- }
- }
- void ektypwsi() {
- int i,j,k;
- for (i=0; i<M; i++) {
- for (j=0; j<M; j++) {
- scanf("%d", &plegma[i][j]);
- }
- }
- for (j=0; j<M; j++) {
- printf(" %d ", j );
- if (j==2) {
- printf(" ");
- }
- if (j==5) {
- printf(" ");
- }
- }
- printf("\n=======================================\n");
- for (i=0; i<18; i++) {
- if ( (i%2==1) && (i!=5) && (i!=11) && (i!=17) ) {
- printf("---------------------------------------\n");
- }
- if ( i==5 || i==11 || i==17 ) {
- printf("=======================================\n");
- }
- if ( i%2==0 ) {
- k=i/2;
- for (j=0; j<M; j++) {
- if (plegma[k][j]!=0) {
- if (j!=3 && j!=6) {
- printf("| %d ", plegma[k][j]);
- }
- else {
- printf("|| %d ", plegma[k][j]);
- }
- }
- else {
- if (j!=3 && j!=6) {
- printf("| ");
- }
- else {
- printf("|| ");
- }
- }
- }
- if (j==9) {
- printf("| %d\n", k);
- }
- }
- }
- }
- int main(int argc, char* argv[]) {
- int i,grammh,sthlh,arithmos;
- char apantisi[N];
- eisagwgi();
- /*stadio 2*/
- do {
- ektypwsi();
- printf("What do you want to do?\n");
- scanf("%6s", apantisi);
- for (i=0; i<N; i++) {
- apantisi[i]=tolower(apantisi[i]);
- }
- if (strcmp(apantisi,"insert")== 0) {
- printf("TRY: insert X in (R, C)\n");
- scanf("insert %d in %d,%d", &arithmos, &grammh, &sthlh);
- if (arithmos<1 || arithmos>9) {
- printf("Number out of range.Insert aborted\n");
- continue;
- }
- if (plegma[grammh][sthlh]!=0) {
- printf("Non-empty cell. Insert aborted.\n");
- continue;
- }
- if (grammh<0 || grammh>8 || sthlh<0 || sthlh>8) {
- printf("Location out of range.Insert aborted\n");
- continue;
- }
- }
- else if (strcmp(apantisi,"delete")==0) {
- printf("TRY: delete (R, C)\n");
- scanf("delete %d,%d", &grammh, &sthlh);
- if (grammh<0 || grammh>8 || sthlh<0 || sthlh>8) {
- printf("Location out of range.Delete aborted\n");
- continue;
- }
- }
- }while (strcmp(apantisi,"quit")!=0);
- printf("QUITTING");
- printf("Thank you! Play again.");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement