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

C_ÅжÏÓï¾äifÓëelseµÄǶÌ×ʹÓÃ

 Ô´Âë:
# include <stdio.h>
 
int main()
{
    /* sex´ú±íÊäѪÕßµÄÐÔ±ð£¬weight´ú±íÊäѪÕßµÄÌåÖØ£¬cubage´ú±íÊäѪÁ¿ */
    int sex, weight, cubage;
    printf("Çë¸ø³öÊäѪÕßµÄÐÔ±ð£¨Å®ÐÔΪ¸ºÊý£©ºÍÌåÖØ£º(ÓöººÅ¸ô¿ª)");
    scanf("%d,%d", &sex, &weight);
 
    if(sex >= 0)    /* Èô±äÁ¿sexµÄÊýֵΪ·Ç¸ºÊý£¬Ôò±íʾΪÄÐÐÔ */
    {
        if(weight >= 120)
        {
            cubage = 200;
            printf("´ËÈËÓ¦¸ÃÊäѪ£º%dºÁÉý\n", cubage);
        }
        else
        {
            cubage = 180;
            printf("´ËÈËÓ¦¸ÃÊäѪ£º%dºÁÉý\n", cubage);
        }
    }
    else   /* ·ñÔò£¬±íʾΪŮÐÔ */
    {
        if(weight >= 100)
        {
            cubage = 150;
            printf("´ËÈËÓ¦¸ÃÊäѪ£º%dºÁÉý\n", cubage);
        }
        else
        {
            cubage = 120;
            printf("´ËÈËÓ¦¸ÃÊäѪ£º%dºÁÉý\n", cubage);
        }
    }
    return 0;
}


Ïà¹ØÎĵµ£º

extern ¡°C¡±Ó÷¨

ÓÃÒ»¾ä»°¸ÅÀ¨extern “C”Õâ¸öÉùÃ÷µÄÕæʵĿµÄ¾ÍÊÇʵÏÖC++ÓëC¼°ÆäËüÓïÑԵĻìºÏ±à³Ì¡£
extern "C"µÄ¹ßÓ÷¨
£¨1£©ÔÚC++ÖÐÒýÓÃCÓïÑÔÖеĺ¯ÊýºÍ±äÁ¿£¬ÔÚ°üº¬CÓïÑÔÍ·Îļþ£¨¼ÙÉèΪcExample.h£©Ê±£¬Ðè½øÐÐÏÂÁд¦Àí£º
extern "C"
{
££i nclude "cExample.h"
}
¶øÔÚCÓïÑÔµÄÍ·ÎļþÖУ¬¶ÔÆäÍⲿº¯ÊýÖ»ÄÜÖ¸¶¨ÎªexternÀà ......

cÄÚ´æ·ÖÅä

ÄÚ´æ·ÖÅ䷽ʽÓÐÈýÖÖ£º
£¨1£© ´Ó¾²Ì¬´æ´¢ÇøÓò·ÖÅä¡£ÄÚ´æÔÚ³ÌÐò±àÒëµÄʱºò¾ÍÒѾ­·ÖÅäºÃ£¬Õâ¿éÄÚ´æÔÚ³ÌÐòµÄ
Õû¸öÔËÐÐÆڼ䶼´æÔÚ¡£ÀýÈçÈ«¾Ö±äÁ¿£¬static ±äÁ¿¡£
£¨2£© ÔÚÕ»ÉÏ´´½¨¡£ÔÚÖ´Ðк¯Êýʱ£¬º¯ÊýÄÚ¾Ö²¿±äÁ¿µÄ´æ´¢µ¥Ôª¶¼¿ÉÒÔÔÚÕ»ÉÏ´´½¨£¬º¯
ÊýÖ´ÐнáÊøʱÕâЩ´æ´¢µ¥Ôª×Ô¶¯±»ÊÍ·Å¡£Õ»ÄÚ´æ·ÖÅäÔËËãÄÚÖÃÓÚ´¦ÀíÆ÷µÄÖ¸Áî¼ ......

ÓÃC# ʵÏÖC/SģʽÏÂÈí¼þ×Ô¶¯ÔÚÏßÉý¼¶

 Õª   Òª£º
¡¡±¾ÎÄÕë¶ÔÄ¿Ç°C/SģʽϱàдµÄÓ¦ÓóÌÐò¿Éά»¤ÐÔ²îµÄÌص㣬Ìá³öÁËÒ»Ì××Ô¶¯ÔÚÏßÉý¼¶µÄ½â¾ö·½°¸£¬·ÖÎöÁËÔÚÏßÉý¼¶µÄÀ§ÄѼ°ÊµÏÖÔ­Àí£¬²¢¸ø³öÁËʵÏÖÉý¼¶µÄ²¿·Ö´úÂ룬¾ßÓÐʵ¼Ê²Î¿¼¼ÛÖµºÍÏÖʵÒâÒå¡£±¾ÎijÌÐò´úÂë¾ùÔÚ.Net Framework 1.1 ºÍWindows2000ϲâÊÔͨ¹ý¡£
¡¡¹Ø¼ü´Ê£ºC#£»ÔÚÏßÉý¼¶£»×Ô¶¯Éý¼¶£ ......

C_ÆÕͨλÔËËã

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

C_³õʶָÕë

 Ô´Âë:
# include <stdio.h>
 
int main()
{
    /* ¶¨ÒåÒ»¸öÕûÐÎÖ¸Õëp */
    int *p;
    int begin, end;
 
    begin = 10;
    /* ¸øÖ¸Õëp¸³³õÖµ */
    p = &begin;
  & ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ