Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*------------------------------------------------------------------------------
- HELLO.C
- Copyright 1995-1999 Keil Software, Inc.
- ------------------------------------------------------------------------------*/
- #include <REG52.H> /* special function register declarations */
- /* for the intended 8051 derivative */
- #include <stdio.h> /* prototype declarations for I/O functions */
- #ifdef MONITOR51 /* Debugging with Monitor-51 needs */
- char code reserve [3] _at_ 0x23; /* space for serial interrupt if */
- #endif /* Stop Exection with Serial Intr. */
- /* is enabled */
- void swap(int *a, int *b)
- {
- int tmp=*b;
- *b = *a;
- *a = tmp;
- }
- /*------------------------------------------------
- The main C function. Program execution starts
- here after stack initialization.
- ------------------------------------------------*/
- int main (void)
- { //=============�ܼƽЫŧi��U��=============//
- int score[2][10]={{0},{0}};
- int i,j,count=0;
- /*------------------------------------------------
- �]�w��C��(19200 BAUD 11.0592MHZ)
- ------------------------------------------------*/
- #ifndef MONITOR51 /*�]�w��C��(19200 BAUD 11.0592MHZ) */
- SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */
- TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */
- TH1 = 0xfd; /* TH1: reload value for 9600 baud @ 11.0592MHZ */
- PCON |= 0x80; /* SMOD=1: Double the baud rate to 19200 @ 11.0592MHZ */
- TR1 = 1; /* TR1: timer 1 run */
- TI = 1; /* TI: set TI to send first char of UART */
- #endif
- /*------------------------------------------------
- Note that an embedded program never exits (because
- there is no operating system to return to). It
- must loop and execute forever.
- ------------------------------------------------*/
- //=============�{���X��g��U��=============//
- printf("��J�Ǹ� �b��J���� �@�Q��:\n");
- for(i=0;i<10;i++)
- scanf("%d%d",&score[0][i],&score[1][i]);
- for(i=10;i>0;i--) {
- for(j=0;j<i-1;j++) {
- if(score[1][j]>score[1][j+1]){
- swap(&score[0][j], &score[0][j+1]);
- swap(&score[1][j], &score[1][j+1]);
- count++;
- }
- }
- }
- printf("\n�Ѥp�ƨ�j��:\n�Ǹ�\t����\n");
- for(i=0;i<10;i++)
- printf("%d\t%d\n", score[0][i],score[1][i] );
- printf("%d",count);
- while(1);
- }//=====================�{���X����=====================//
Advertisement
Add Comment
Please, Sign In to add comment