Go4Expert (http://www.go4expert.com/)
-   Meet and Greet (http://www.go4expert.com/community/meet-and-greet/)
-   -   timer (http://www.go4expert.com/community/timer-t25153/)

johnny12 4Mar2011 18:00

this is my code, I dont know why it will not run perfectly?

int easy(int z)//EASY ROUND PROBLEM
    int elapTicks;

    double elapMilli, elapSeconds, elapMinutes;

    clock_t Begin, End;            //initialize Begin and End for the timer
      int cells (int z){
      char sudoku_prob[Z][Y][X]={
  Begin = clock() * CLK_TCK;    //begin the timer
  // for(int a=1; a<=10000; a++);
      //initialization of a 3D array where array[Z][Y][X] in a 3D Cartesian plane
          int i=1,x, y,check=0;
              for (y=0; y<Y; y++){
                        for (x=0; x<X; x++)
                        printf("%4c", sudoku_prob[z][y][x]);
            case 0:    printf("\nEnter for A: ");sudoku_prob[z][0][2]=getchar();getchar();
                      printf("Enter for B: ");sudoku_prob[z][0][5]=getchar();getchar();
                      printf("Enter for C: ");sudoku_prob[z][1][4]=getchar();getchar();
                      printf("Enter for D: ");sudoku_prob[z][2][1]=getchar();getchar();
                      printf("Enter for E: ");sudoku_prob[z][2][6]=getchar();getchar();
                      printf("Enter for F: ");sudoku_prob[z][3][2]=getchar();getchar();
                      printf("Enter for G: ");sudoku_prob[z][4][0]=getchar();getchar();
                      printf("Enter for H: ");sudoku_prob[z][4][4]=getchar();getchar();
                      printf("Enter for I: ");sudoku_prob[z][5][2]=getchar();getchar();
                      printf("Enter for J: ");sudoku_prob[z][5][8]=getchar();getchar();
                      printf("Enter for K: ");sudoku_prob[z][0][0]=getchar();getchar();
                      printf("Enter for L: ");sudoku_prob[z][6][5]=getchar();getchar();
                      printf("Enter for M: ");sudoku_prob[z][6][8]=getchar();getchar();
                      printf("Enter for O: ");sudoku_prob[z][8][3]=getchar();getchar();
                      printf("Enter for P: ");sudoku_prob[z][8][7]=getchar();getchar();
        default: break;     
          //Checking of answers   
          for (y=0; y<Y; y++){
              for (x=0; x<X; x++){
                  if (sudoku_ans[z][y][x]==sudoku_prob[z][y][x])
            if (check==81)
            printf("\n\nAnswer Correct: Press any key to continue\n\n");
            printf("\n\nAnswer Incorrect: Press any key to continue\n\n");   
        End = clock() * CLK_TCK;        //stop the timer
            return check;       
    elapTicks = End - Begin;        //the number of ticks from Begin to End

    elapMilli = elapTicks/1000;    //milliseconds from Begin to End

    elapSeconds = elapMilli/1000;  //seconds from Begin to End

    elapMinutes = elapSeconds/60;  //minutes from Begin to End

    if(elapSeconds < 1)

          printf("\n\nIt took %d milliseconds.", elapMilli);

    else if(elapSeconds == 1)

          printf("\n\nIt took  1 second.");

    else if(elapSeconds > 1 && elapSeconds < 60)

          printf("\n\nIt took %d seconds.", elapSeconds);

    else if(elapSeconds >= 60) 

          printf("\n\nIt took  %d minutes.", elapMinutes);

  return 0;


All times are GMT +5.5. The time now is 19:33.