예제 #1
0
int main(){

	//create an array of sudents
	Student students[MAX_NUMBER_OF_STUDENTS];
	unsigned int number_of_students =0;

	//open the file (quit with an error if the file was not opened correctly)
	std::ifstream scores(SCORES_FILE);
	if (!scores) {
		std::cerr << "File does not exist.\n";
		exit(EXIT_FAILURE);
	}

	//read in the student data and store the data for each of the students.
	//stop reading data when the aray is full or when there is no more data
	for (int i =0; students[i].readFromFile(scores); ++i) {
		++number_of_students;
	}

	Print_Table(students, number_of_students);
	Print_Average(students, number_of_students);

	//system("PAUSE");


	return EXIT_SUCCESS;
}
예제 #2
0
파일: rox.c 프로젝트: baiwei0427/XPath
static int device_ioctl(struct file *file, unsigned int ioctl_num, unsigned long ioctl_param) 
{
        struct Rule* r;
        unsigned long flags;
        switch (ioctl_num) 
		{
            //Insert a new rule to rules
            case IOCTL_ROX_INSERT_RULE:
                //printk(KERN_INFO "Inset a new rule\n");
                r=(struct Rule*)ioctl_param;
                //Print new rule
                print_rule(r);
                //Insert this new rule to RuleTable
                write_lock_irqsave(&my_rwlock,flags);
                Insert_Table(&rt,r,GFP_ATOMIC);
                write_unlock_irqrestore(&my_rwlock,flags);
                //Print_Table(&rt);
                break;

            //Delete a rule from rules
            case IOCTL_ROX_DELETE_RULE:
                r=(struct Rule*)ioctl_param;
                //Print new rule
                //print_rule(r);
                //Delete thie rule from RuleTable
                write_lock_irqsave(&my_rwlock,flags);
                Delete_Table(&rt,r);
                write_unlock_irqrestore(&my_rwlock,flags);
                //Print_Table(&rt);
                break;

            //Update a rule
            case IOCTL_ROX_UPDATE_RULE:
                r=(struct Rule*)ioctl_param;
                //Print new rule
                //print_rule(r);
                //Update this new rule to RuleTable
                write_lock_irqsave(&my_rwlock,flags);
                Update_Table(&rt,r);
                write_unlock_irqrestore(&my_rwlock,flags);
                //Print_Table(&rt);
                break;
			
			//Print current rule table
			case IOCTL_ROX_PRINT_RULE:
				Print_Table(&rt);
				break;
        }
        //spin_unlock(&globalLock);
        return SUCCESS;
}
예제 #3
0
파일: tempest.c 프로젝트: shuGH/prjC
/*--------------------------------------------*/
int main (void) {
  int flg=0;                    /* 反転可能フラグ(0 不可, 1 可) */
  int nT = 0;                   /* ターン数 */
  int Order[3];                 /* 順番保存配列 */
  int i;

  /* 各リストのポインタの初期化 */
  for (i=0; i<Depth+1; i++) { List[i].next=NULL; }

  Reset_Table(0);               /* 盤の初期化 */
  Print_Title(Order);           /* タイトルの表示 */
  printf("[ Game Start ]\n\n");

  /* メインループ */
  while(1) {
 
    /* 順位の計算 */
    Count_Stone(0);
    Sort_Num();                 

    /* 終了判定 */
    if (Player[0].Num==0) { break; } /* 全マスが埋まったとき */

    /* ターンと順位の表示 */
    printf("[ Turn %02d ] P%d %s ", nT+1,Order[nT%3],Player[Order[nT%3]].Mark);
    if (Player[Order[nT%3]].Rank==1) { printf("1st\n\n"); }
    if (Player[Order[nT%3]].Rank==2) { printf("2nd\n\n"); }
    if (Player[Order[nT%3]].Rank==3) { printf("3rd\n\n"); }

    /* 反転判定と盤面の表示 */
    flg = Check_Table(0,Order[nT%3]);
    Print_Table(0,flg);
    if (Debug) { Print_Debug(0,Order[nT%3],flg); }

    /* 各プレーヤーの個数の表示 */
    printf("\n%s:%02d %s:%02d ", Player[0].Mark, Player[0].Num,Player[Order[0]].Mark, Player[Order[0]].Num);
    printf("%s:%02d %s:%02d\n\n",  Player[Order[1]].Mark, Player[Order[1]].Num,Player[Order[2]].Mark, Player[Order[2]].Num);

    /* 石の設置 */
    if (Player[Order[nT%3]].St==0) { /* CPU */
      Put_Stone(0,Order[nT%3],AI_AlphaBeta(0,Order[nT%3],0,-maxVal,maxVal));
      printf("EnterKey : ");
      while(getchar() != '\n');
      printf("\n");
      nT++;        /* 次ターンへ */
    } else if (Player[Order[nT%3]].St==1) { /* Man */
      Put_Stone(0,Order[nT%3],Input_Pos(0,Order[nT%3],flg));
      getchar();
      printf("\n");
      nT++;        /* 次ターンへ */
    }

    /* 全リストのメモリ開放 */
    for (i=0; i<Depth+1; i++) { Free_ListMemory(i); }
  }

  /* 結果の表示 */
  printf("[ Game Over ]\n\n");
  Print_Table(0,0);
  printf("\n");
  Honor_Platform();

	return 0;
}