Esempio n. 1
0
void dealerTurn(table *t, deck *d) {
    
    assert((t) && (d));
    
    showCard(t->dealer->playerHand->cards[0]);
    sleep(1);
    displayTable(t, 1);
    
    /*Condition for soft 17*/
    if ((t->dealer->playerHand->score == 17) &&
        (t->dealer->playerHand->cardCount == 2) &&
        (isHiAce(t->dealer->playerHand->cards[0]) ||
         isHiAce(t->dealer->playerHand->cards[1]))) {
            dealCard(t, d, t->dealer, 1);
            assessHand(t->dealer->playerHand);
            sleep(1);
            displayTable(t, 1);
    }
    
    while (t->dealer->playerHand->score < 17) {
        dealCard(t, d, t->dealer, 1);
        assessHand(t->dealer->playerHand);
        sleep(1);
        displayTable(t, 1);
    }
}
Esempio n. 2
0
File: hash.c Progetto: sagar13/temp
int main()
{
	int choice;
	char ans = 'y';
	char fname[SIZE];
	struct linknode *hashTable[TABLESIZE];
	initializeHashTable(hashTable);
	
	while(ans == 'y')
	{
		printf("\n1. Create file\n");
		printf("2. Delete File\n");
		printf("3. Search File\n");
		printf("4. Display Table\n");
		printf("5. Exit\n");
		printf("6. Write to disk\n");
		printf("7. Read from disk\n");
		printf("\nEnter choice: ");
		scanf("%d", &choice);
		switch(choice)
		{
			case 1:
				printf("Enter file name: ");
				scanf("%s", fname);
				insertFile(fname, hashTable);
				break;

			case 2:
				printf("Enter file name: ");
				scanf("%s", fname);
				deleteFile(fname, hashTable);
				break;

			case 3:
				printf("Enter file name: ");
				scanf("%s", fname);
				searchFile(fname, hashTable);
				break;

			case 4:
				displayTable(hashTable);
				break;

			case 5:
				exit(0);

			case 6:
				writeToDisk(hashTable);
				break;

			case 7:
				readFromDisk(hashTable);
				break;
		}
	}
	return (0);
}
int main(void){
	// 顯示陣列
	int bingoTable[SIZE][SIZE] = {0};
	int playerTable[SIZE][SIZE] = {0};
	int *tmpRand;
	int score = 0;
	int guessTime = 0;
	tmpRand = createRandNum();
	setValueInTable(tmpRand, bingoTable);
	
	// 以下為 while or do while
	while(score < 3){
		printf("|隱藏的賓果盤|\n");
		displayTable(bingoTable);
		printf("|玩家戳號盤|\n");
		displayTable(playerTable);
		printf("Score:%d\n", score);
		int number;
		printf("Plz input a number:");
		scanf(" %d", &number);
		selectNumber(bingoTable, playerTable, number);
		guessTime++;
		score = score
			+	checkRow(playerTable)
			+	checkColumn(playerTable)
			+	checkCross(playerTable);
		system("CLS");
	}
	printf("|隱藏的賓果盤|\n");
	displayTable(bingoTable);
	printf("|玩家戳號盤|\n");
	displayTable(playerTable);
	printf("恭喜結束遊戲\n");
	printf("Score:%d\n", score);
	printf("猜測次數:%2d\n", guessTime);
	system("pause");
	return 0;
}
Esempio n. 4
0
int main() {
    table tList;

    // Create table of events
    tList = createTable(NUMTASKS, NUMRES, OVERHEAD);

    // populateTask(tList.tasks, "name", run, per);
    // must be done from smallest to largest period
    populateTask(tList.tasks, "Compute Altitude Data", 1300, 2560);
    populateTask(tList.tasks + 1, "Compute Velocity Data", 4700, 40960);
    populateTask(tList.tasks + 2, "Compose Altitude Message", 9000, 61440);
    populateTask(tList.tasks + 3, "Display Data", 23000, 1000000);
    populateTask(tList.tasks + 4, "Compose Navigation Message", 38300, 1024000);
    populateTask(tList.tasks + 5, "Compute Position Data", 3000, 1280000);

    // Resources
    makeResources(&tList);

    // fillResource(&tList, task, res, useTime);
    fillResource(&tList, 0, 0, 200);
    fillResource(&tList, 0, 1, 0);
    fillResource(&tList, 1, 0, 200);
    fillResource(&tList, 1, 1, 0);
    fillResource(&tList, 2, 0, 150);
    fillResource(&tList, 2, 1, 3000);
    fillResource(&tList, 3, 0, 300);
    fillResource(&tList, 3, 1, 0);
    fillResource(&tList, 4, 0, 300);
    fillResource(&tList, 4, 1, 6000);
    fillResource(&tList, 5, 0, 200);
    fillResource(&tList, 5, 1, 0);

    // Blocking
    calculateBlocking(&tList);

    // Print table
    displayTable(&tList);

    // RMA algorithm
    if (rma(tList))
        printf("\nAll tasks schedulable!\n\n");

    return 0;
}
Esempio n. 5
0
int main() {
    /*Se hace un test con la cadena hexadecimal 6F1A840E315041592E5359532E4444463031A5088801025F2D02656E
    cuyo significado es el siguiente:
    6F(File Control Information(FCI) Template)
    	1A
    	84(Dedicated File(DF) Name)
    		0E -len
    		315041592E5359532E4444463031 - value(1PAY.SYS.DDF01 en hexa)
    	A5(File Control information(FCI) Propietary template)
    	08-len
    		88(Short File Identifier(SFI))
    			01- len
    			02 -value
    		5F2D(language preference)
    			02-len
    			656E-value
    */

    dict_t *dict[HASHSIZE];
    memset(dict, 0, sizeof(dict));
    emvInit(dict);
    displayTable(dict);

    unsigned char test[] = {0x6F,0x1A,0x84,0x0E,0x31,0x50,0x41,0x59,0x2E,0x53,0x59,
                            0x53,0x2E,0x44,0x44,0x46,0x30,0x31,0xA5,0x08,0x88,0x01,
                            0x02,0x5F,0x2D,0x02,0x65,0x6E,
                            0x6F,0x1A,0x84,0x0E,0x31,0x50,0x41,0x59,0x2E,0x53,0x59,
                            0x53,0x2E,0x44,0x44,0x46,0x30,0x31,0xA5,0x08,0x88,0x01,
                            0x02,0x5F,0x2D,0x02,0x65,0x6E
                           };
    //unsigned char test[] = {0x9F, 0x35, 0x00}; //consulta de tag
    unsigned short size = sizeof(test)/sizeof(test[0]);
    tlvInfo_t *t=malloc(sizeof(tlvInfo_t)*size);
    memset(t,0,size);
    tlvInfo_init(t);
    int tindex =0;
    emvparse(test, size, t, &tindex , 0, dict);
    emvPrint_result(t, tindex);

    return 0;
}
Esempio n. 6
0
void playerTurn(table *t, player *p, deck *d) {

    char ans;
    ans = 'd';
    assert((t) && (p) && (d));
    
    while ((ans != 's') && (p->playerHand->bust != 1)) {
        printf("Hit: h\tStay: s\n");
        newlines(1);
        tabs(t->margin);
        spaces(t->buffer);
        ans = getchar();
        
        if (ans == 'h') {
            dealCard(t, d, p, 1);
        }
        assessHand(p->playerHand);
        displayTable(t, 1);

    }
}
Esempio n. 7
0
int main()
{
  int choice=0;
  int k,a,i;
  char nam[20];
  struct node *temp;
  hashTable=initializeHT(BKT_NUM);
  struct hash*temp1;
  hashTable=(struct hash*)malloc(sizeof(struct hash)*BKT_NUM);
  for(i=0;i<BKT_NUM;i++)
    {
      hashTable[i].head=NULL;
      hashTable[i].count=0;
    }
  while(choice!=3)
    {
      printf("\n Enter Choice: ");
      scanf("%d",&choice);
      switch(choice)
	{
	case 1:
	  printf("Enter the key:");
	  scanf("%d",&k);
	  printf("Enter the name:");
	  scanf("%s",nam);
	  printf("Enter the age:");
	  scanf("%d",&a);
	  temp=createNode(k,nam,a);
	  insert(temp);
	  break;
	case 2:
	  displayTable(hashTable);
	  break;
	default:
	  break;
	}
    }
  return 0;
}
Esempio n. 8
0
Qt1::Qt1(QWidget *parent):QDialog(parent)
{
	setupUi(this);
	connect(pbOK,SIGNAL(clicked()),this,SLOT(fun()));
	connect(pbExit,SIGNAL(clicked()),this,SLOT(fun2()));

	le1->setAlignment(Qt::AlignRight);
//	le1->setMaxLength(4) ;
//	le2->setEchoMode(2);
	leRes->setReadOnly(true);

//	textchanged信号和textedit信号两者的一个区别在于,
//	textchanged信号是在文本有任何改变的时候就会触发这样的一个信号,
//	无论是编辑还是设置,都会触发这样的一个textchanged信号;
//	而textedit信号只是在编辑的时候才会发出这样的一个信号。
//	信号带参数的时候,不要给出参数名,只须给出参数类型即可。
	connect(le1,SIGNAL(textEdited(const QString &)),this,SLOT(fun1(QString)));
	connect(le2,SIGNAL(textChanged(const QString &)),this,SLOT(fun3(QString)));
	displayTable();

	connect(pbqqqq,SIGNAL(clicked()),tabWidget,SLOT(hide()));
	//qtabwidget当前页的改变,将会发送一个currentChanged信号
	connect(tabWidget,SIGNAL(currentChanged(int)),this,SLOT(tellme(int)));
}
Esempio n. 9
0
void Dijkstra( int s)
{
	int i,current;
	
	/* Make all vertices temporary */
	for(i=0; i<n; i++)
	{
		predecessor[i] =  NIL;   
		pathLength[i] = infinity;
		status[i] = TEMP;
	}
	/* Make pathLength of source vertex equal to 0 */
	pathLength[s] = 0;
		
	while(1)
	{
		
		/*Search for temporary vertex with minimum pathLength and make it current vertex*/
		displayTable();
		current = min_temp( );
		printf("Current vertex is  %d\n\n", current);
		STOP;

		if( current == NIL )
		{
			printf("Now either there are no temporary vertices or\n");
			printf("all temporary vertices have pathLength infinity\n");
			return;
		}

		status[current] = PERM;

		for(i=0;i<n;i++)
		{
			/*Checks for adjacent temporary vertices */
			if ( adj[current][i] !=0 && status[i] == TEMP )
			{
				printf("Vertex %d is temporary, and is adjacent to current vertex %d\n", i, current);
				if( pathLength[current] + adj[current][i] < pathLength[i] )
				{	
					printf("pathLength(%d) + weight(%d,%d) < pathLength(%d)\n",current,current,i,i);
					printf("%d +  %d < %d\n",pathLength[current],adj[current][i],pathLength[i]);
					printf("Relabel vertex %d\n",i);
					predecessor[i] = current; 
					pathLength[i] = pathLength[current] + adj[current][i];    
					printf("pathLength[%d] = %d,",i,pathLength[current] + adj[current][i]);    
					printf("predecessor[%d] = %d\n\n ",i,current);
				}
				else
				{
					if( pathLength[current] + adj[current][i] == pathLength[i] )
					{
						printf("pathLength(%d) + weight(%d,%d) = pathLength(%d)\n",current,current,i,i);
						printf("%d +  %d = %d\n",pathLength[current],adj[current][i],pathLength[i]);
					}
					else
					{
						printf("pathLength(%d) + weight(%d,%d) > pathLength(%d)\n",current,current,i,i);
						printf("%d +  %d > %d\n",pathLength[current],adj[current][i],pathLength[i]);
					}
					printf("Don't Relabel vertex %d\n\n",i);
				}
				STOP;
			}	
		}
	}
}/*End of Dijkstra( )*/