Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

C_ʹÓÃһάÊý×éʵÏÖÑ¡ÔñÅÅÐò·¨

 Ô´Â룺
/* ʹÓÃÑ¡Ôñ·¨ÅÅÐò */
# include <stdio.h>
 
int main()
{
    int i, j, min, temp;
    /* ¶¨ÒåÒ»¸öÕûÐ͵ÄһάÊý×é */
    int array[10];
    /* ÊäÈëÊý¾Ý */
    printf("Please input ten integer: \n");
    for(i=0; i<10; i++)
    {
        printf("array[%d] = ", i);
        scanf("%d", &array[i]);
    }
    printf("The array is: ");
    for(i=0; i<10; i++)
        printf("%d ", array[i]);
    printf("\n");
    /* ÅÅÐò */
    for(i=0; i<9; i++) //˳×Å0µ½×îºóÒ»¸öÔªËØ½øÐÐÑ¡ÔñÅÅÐò£¨µÝÔö£©
    {
        min = i;
        for(j=i; j<10; j++) //ÿ´Î×ÜÈõÚi¸öÔªËØÍ¬ÆäºóµÄÔªËØ×ö±È½Ï£¬×îСÕßÉÏλ
            if(array[min]>array[j]) min = j;
        temp = array[i];
        array[i] = array[min];
        array[min] = temp;
    }
    /* Êä³ö */
    printf("\nThe result: \n");
    for(i=0; i<10; i++)
        printf("%d ", array[i]);
    printf("\n");
    return 0;
}


Ïà¹ØÎĵµ£º

C/C++ʱ¼äº¯ÊýʹÓ÷½·¨£¨×ª£©

C++¶Ôʱ¼äµÄ²Ù×÷Ò²ÓÐÐí¶àÖµµÃ´ó¼Ò×¢ÒâµÄµØ·½¡£×î½ü£¬ÔÚ¼¼ÊõȺÖÐÓкܶàÍøÓÑÒ²¶à´ÎÎʵ½¹ýC++ÓïÑÔÖжÔʱ¼äµÄ²Ù×÷¡¢»ñÈ¡ºÍÏÔʾµÈµÈµÄÎÊÌâ¡£ÏÂÃæ£¬ÔÚÕâÆªÎÄÕÂÖУ¬±ÊÕß½«Ö÷Òª½éÉÜÔÚC/C++ÖÐʱ¼äºÍÈÕÆÚµÄʹÓ÷½·¨.
         ͨ¹ýѧϰÐí¶àC/C++¿â£¬Äã¿ÉÒÔÓкܶà²Ù×÷¡¢Ê¹ÓÃʱ¼äµÄ·½·¨¡£µ«Ô ......

C_תÒå×Ö·û

 Ô´Âë:
# include <stdio.h>
 
int main()
{
    /* »»Ðзû'\n'£¬ÓÃÓÚÊä³ö»»ÐÐ */
    printf("How are you?\n");
    printf("I am fine.\n\n");
 
    /* ºáÏòÌø¸ñ·û'\t'£¬Ê¹Ìøµ½ÏÂÒ»¸öÊä³öÇø */
  ......

C_ÆÕͨλÔËËã

 Ô´Âë:
# include <stdio.h>
 
int main()
{
    /* ¶¨ÒåÁËÒ»¸öÎÞ·ûºÅ×Ö·ûÐͱäÁ¿£¬´Ë±äÁ¿Ö»ÄÜÓÃÀ´´æ´¢ÎÞ·ûºÅÊý */
    unsigned char result;
    
    int a, b, c, d;
    a = 2;
    b = 4; ......

C_¸Ä±ä×Ö·û±àÂëʵÏÖ¼òµ¥¼ÓÃÜ

 Ô´Âë:
# include <stdio.h>
 
int main()
{
    /* ¶¨Òå×Ö·ûÐͱäÁ¿£¬²¢¸øËüÃǸ¶³õÖµ */
    char c1, c2, c3, c4, c5, c6, c7;
    c1 = 'C';
    c2 = 'h';
    c3 = 'i';
    c4 = 'n';
 & ......

C_ÔËÓÃdo

 Ô´Â룺
# include <math.h>
# include <stdio.h>    /* Êýѧº¯Êý¿â */
 
int main()
{
    /* ÓÃs±íʾ¶àÏîʽµÄÖµ£¬ÓÃt±íʾÿһÏîµÄÖµ */
    double s, t, x; // ´Ë´¦ÓÃË«¾«¶ÈÉùÃ÷±äÁ¿
    int n;
    printf ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ