コード例 #1
0
int main()
{
	 char buffer[40];
	 int control,counter=0;
	 char *a, *b ,*c;
	 FILE *fp;
	 ATHLETEPNT   athleteList; //tempPnt;
	 printf(" \n\n******************************************************\n");
	 printf(" *             RANKING OF RACE                          *\n");
	 printf("******************************************************\n\n\n");
	 do
	 {
				 control=0;
	 if((fp= fopen("race.txt","r"))==NULL)
	 {
			printf("file could not open\n");
			control=1;
			}
	 else{
			 printf("the read file is as \n\n");
	   printf("<Athlete id> \t <Arrival time>\n");
             headList=NULL;
	 while(fgets(buffer,39,fp)!=NULL)
	 {
	 athleteList=(ATHLETEPNT)malloc(sizeof(struct athlete));
	 
	 sscanf(buffer,"%d %s",&athleteList->id,athleteList->time);


		athleteList->nextList=headList;
		headList=athleteList;
		counter++;
		//printf(" the time : %s ",athleteList->time);
		
		a=strtok(athleteList->time,":" );
		b=strtok(NULL,":" );
		c=strtok(NULL,":" );
		//printf(" a= %s b=%s c=%s ",a,b,c);
		athleteList->hour=atoi(a);
		athleteList->min=atoi(b);
		athleteList->sec=atoi(c);
		printf("\t %d \t %+d:%02d:%02d \n",athleteList->id,athleteList->hour,athleteList->min,athleteList->sec);
		
					}//end while
			}// end else
			Ranking(headList , counter);// fuction call



  system("PAUSE");

}while(control);
 return 0;
}
コード例 #2
0
ファイル: Ranking.c プロジェクト: MJayJang/ParkCom
//Define Functions
int main(int argc, char *argv[]){
	ULong scores[MAX];
	ULong numbers[MAX];
	ULong ranks[MAX];

	Input(scores);
	Ranking(numbers, scores, ranks);
	Output(numbers, scores, ranks);

	return 0;
}
コード例 #3
0
ファイル: Principal.cpp プロジェクト: alex2992/granota
int main()
{
	char opcio;
	int punts;
	int posicio = -1;
	char nivell = '1';
	Ranking ranking = Ranking();
	Jugador nouJugador;
	int filaGotoXY=9;

	do
	{
		mostraMenuPrincipal();
		opcio = _getch(); // Llegeix tecla apretada
		switch (opcio)
		{
			case OPCIO_JUGAR:
			
				punts = juga(nivell-'0'); // COMPTE!: aquí hi ha una conversió de char a int
				nouJugador = Jugador(punts);
				if (ranking.afegirJugador(nouJugador))
					cout << "\n Enhorabona!!! Has entrat al ranking dels " << MAX_JUGADORS << "millors jugadors!!\n";
				else
					cout << "\n Llàstima! No has pogut entrar al ranking dels " << MAX_JUGADORS << "millors jugadors. \n";
				break;
			case OPCIO_CONFIGURAR:
				do
				{
					mostraMenuNivellDificultat();
					nivell = _getch(); // Llegeix tecla apretada
					if ((nivell != '1') && (nivell != '2') && (nivell != '3')) // Comprova si tecla es valida
					{
						cout << "Opcio incorrecta.\n"; // Mostra text
						
					}
				} while ((nivell != '1') && (nivell != '2') && (nivell != '3')); // Repeteix mentre tecla no valida
				break;
			case OPCIO_PUNTUACIO:
				ranking.mostrar();
				cout << "Prem una tecla per tornar al menu principal";
				_getch(); // Llegeix tecla apretada
				break;
		}
	} while (opcio != OPCIO_SORTIR);
	
	return 1;
}