CµÄenum struct ÒÔ¼° JavaµÄenum
ÔÚcÖÐenumµÄʹÓúÍstructºÜÏñ
enum name{
a,b,c
};
struct name{
int a;
int b;
char c;
};
or
typedef struct{
int a;
int b;
char c;
}Name;
ʹÓõÄʱºò¶¼ÒªÏÈÉùÃ÷±äÁ¿
enum name n1,n2,n3;
n1=a;
n2=b;
n3=enum name(3-1);
struct name sn1,sn2;
sn1=(struct name *)malloc(parameter*sizeof(struct name))//ʹÓÃmallocµÄʱºòҪǿÖÆת»»£»
ÔÚjavaÖÐenumµÄʹÓãº
ºÍÀàµÄ¶¨Òå·Ç³£µÄÏàÏñ£¬»òÕßÓгÆΪÊǾ²Ì¬Àࣺ
public enum MyColor{red,yellow,black};
ÔÚʹÓõÄʱºòÒªÏÈnew¶ÔÏó£»
MyColor mc=MyColor.red;//new¶ÔÏó²¢ÇÒ³õʼ»¯£»È»ºó¾Í¿ÉÒÔʹÓÃÕâ¸ö¶ÔÏó£»
public class test{
public enum MyColor{
red;
black;
}
public static void main(String [] args){
MyColor mc= MyColor.red;
switch (mc){
case red:System.out.println("red");break;
case black:System.out.println("black");break;
default:System.out.println("Error");
}
}
}
Ïà¹ØÎĵµ£º
ÄÚ²¿ÀàµÄʹÓõÄÓÅȱµã£º
Óŵ㣺¼õÉÙÁËÔÚÀàÎļþ±àÒëºóµÄ²úÉúµÄ×Ö½ÚÂëÎļþµÄ´óС
ȱµã£ºÊ¹³ÌÐò½á¹¹²»ÇåÎú
ʹÓÃÄÚ²¿ÀàµÄ×¢ÒâÊÂÏ
ÄÚ²¿ÀàµÄʹÓÃÒ»°ã¶¼ÓëËùÔÚµÄÍⲿÀàÓÐÒ»¶¨µÄ¹ØÁª£¬ËüÊÇÔÚÒ»¸öÀàµÄÄÚ²¿Ç¶Ì׶¨ÒåµÄÀ࣬Ëü¿ÉÒÔÊÇÆäËüÀàµÄ³ÉÔ±£¬Ò²¿ÉÒÔÔÚÒ»¸öÓï¾ä¿éµÄÄÚ²¿¶¨Ò壬»¹¿ÉÒÔÔÚ±í´ïʽÄÚ²¿ÄäÃû¶¨Òå(ÄäÃûÄÚ²¿Àà)¡£
ÄÚ²¿ ......
1£®Ç³¸´ÖÆÓëÉÖƸÅÄî
¢Ådz¸´ÖÆ£¨Ç³¿Ë¡£©
±»¸´ÖƶÔÏóµÄËùÓбäÁ¿¶¼º¬ÓÐÓëÔÀ´µÄ¶ÔÏóÏàͬµÄÖµ£¬¶øËùÓеĶÔÆäËû¶ÔÏóµÄÒýÓÃÈÔȻָÏòÔÀ´µÄ¶ÔÏó¡£»»ÑÔÖ®£¬Ç³¸´Öƽö½ö¸´ÖÆËù¿¼ÂǵĶÔÏ󣬶ø²»¸´ÖÆËüËùÒýÓõĶÔÏó¡£
¢ÆÉÖÆ£¨Éî¿Ë¡£©
±»¸´ÖƶÔÏóµÄËùÓбäÁ¿¶¼º¬ÓÐÓëÔÀ´µÄ¶ÔÏóÏàͬµÄÖµ£¬³ýÈ¥ÄÇЩÒýÓÃÆäËû¶ÔÏóµÄ±äÁ¿¡ ......
ÎÒ¾õµÃ,ÔÚÊäÈëÊä³öº¯ÊýÖÐ,scanf()º¯Êý,Ó¦¸ÃÊÇ×îÂé·³µÄ,ÓÐʱËü¸øÎÒÃǵĽá¹ûºÜ¿ÉЦ,µ«ÊÇÒ»¶¨ÊÇÒ»ÔÒòµÄ....
Ê×ÏÈÉùÃ÷Ò»ÏÂ,ÕâƪÈÕÖ¾²»ÊǽéÉÜscanf()Öи÷ÖÖ¸ñʽ·ûÓ÷¨µÄÎÄÕÂ(ûÓÐÕâ¸ö±ØÒª,µ«ÊÇ´ó¼ÒÒ»¶¨Òª»áÓÃ).
ÎÒ³¢ÊÔÁ˺ܶàÖÖÊäÈë,°üÀ¨Ò»Ð©´íÎóµÄÁ·Ï°,Ôø¾¶Ôscanf()ÓÉÃÔãתÏòÇåÐÑ,ÓÖÓÉÇåÐÑÔÙ´ÎתÏòÃÔã......²»ÖªµÀºÎʱÊǸö ......
Cר¼Ò±à³Ì ¾«±àÖ®Ò» µÚÒ»ÕÂ~µÚÈýÕÂ
CµÄ¸´ÔÓÖ®´¦ ÔÚÓÚËüµÄÖ¸Õë ,µ«ÊDZÈÆäÖ¸Õë¸üΪ¸´ÔÓµÄÊÇËüµÄÉùÃ÷ !!!
ÄãÄÜ¿´¶®ËüÃǵÄÒâ˼ Âð?
apple=sizeof(int)*p ; apple=sizeof * p;
j= (char (*)[20])malloc(20);
int const * grape; Óë int * const gr ......