[ create a new paste ] login | about

Link: http://codepad.org/0E61BTOd    [ raw code | output | fork ]

C, pasted on May 5:
#include <stdio.h>
#include <setjmp.h>

int main() {
  jmp_buf env;

  int ary[10][10] = {
    {1,1,1,1,1,1,1,1,1,1},
    {1,1,1,1,1,1,1,1,1,1},
    {1,1,1,1,1,1,1,1,1,1},
    {1,1,1,1,1,1,1,1,1,1},
    {1,1,1,1,1,1,1,1,1,1},
    {1,1,1,1,1,1,1,1,1,1},
    {1,1,1,1,1,1,1,1,1,1},
    {1,1,1,1,1,1,1,1,1,1},
    {1,1,1,1,1,1,1,1,1,1},
    {1,1,1,1,1,1,1,1,1,0},
  };

  if( setjmp(env) == 0 ) {
    /*配列に0が含まれるかチェック*/
    int i, j;
    for (i=0;i<10;i++) {
      for (j=0;j<10;j++) {
        if (ary[i][j]==0) {
          longjmp( env, 1 );
        }
      }
    }
    /*含まれていない場合の処理*/
    printf("0は含ませません\n");
  } else {
    /*含まれていた場合の処理*/
    printf("0が含まれています\n");
  }
  return 0;
}


Output:
1
0が含まれています


Create a new paste based on this one


Comments: