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

C ÓïÑÔÖеÄÀàÐÍת»»ÎÊÌâ

C ÓïÑÔÖеÄÀàÐÍת»»ÎÊÌâ
Ò»¡¢ÎÊÌâµÄÒý³ö
¿´ÏÂÃæÒ»¶Î C ³ÌÐò£º
#include <stdio.h>
int main()
{
short a, b;
float f;
double d;
int i1, i2;

i1 = i2 = 2000000000; //²âÊÔ»·¾³ÖÐ int µÄ±íʾ·¶Î§Îª -2147483648 ~ 2147483647
printf("%d\n", i1+i2); //Òç³ö£¡

a = b = 30000; //²âÊÔ»·¾³ÖÐ short µÄ±íʾ·¶Î§Îª -32768 ~ 32767
printf("%d\n", a+b); //Òç³ö£¿

f = d = 123456789.0;
printf("%f\n", f); //Õý³£Êä³ö£¿
printf("%f\n", d); //Õý³£Êä³ö£¿

return 0;
}

ÔËÐгÌÐòÎÒÃÇ¿´µ½£¬i1+i2 µÄ½á¹ûÀíËùÓ¦µ±µØÒç³öÁË£¬¶ø a+b µÄ½á¹ûȴûÓÐÏñÏëÏóÖеÄÄÇÑùÒç³öΪһ¸ö¸ºÊý¡£
ÁíÍ⣬printf ÖУ¬%f ¶ÔÓÚ float ºÍ double Ð͵ÄÖµ¶¼Äܹ»ÕýÈ·Êä³ö¡£È»¶øÔÚ´ó¶àÊýϵͳÉÏ£¬float ºÍ double µÄÄÚ´æ½á¹¹²¢²»Ïàͬ¡£
ÀàËƵأ¬%d Ò²ÄÜͬʱ½ÓÊÕ short ºÍ int Ð͵ÄÊý¾Ý¡£
ÈçºÎ½âÊÍÉÏÃæµÄÏÖÏó£¿
¶þ¡¢ÎÊÌâµÄ½â´ð——ĬÈÏÀàÐÍת»»
C ÓïÑԹ涨ÁËÒ»ÀàÀàÐÍת»»£¬³Æ×÷“³£ÓÃËãÊõÀàÐÍת»»”£¨Usual arithmetic conversions£©£¬ÓÃÓÚ±í´ïʽÇóÖµµÄÀàÐ͵÷Õû£¬³£¼ûµÄ“µÍ¾«¶ÈÀàÐÍÏò¸ß¾«¶ÈÀàÐÍ¿¿”µÄ˵·¨¼´³öÓÚ´Ë¡£
1¡¢¼¸¸öÖØÒª¸ÅÄî
(1) ËãÊõ£¨arithmetic£©ÀàÐÍ£º°üÀ¨ÕûÐͺ͸¡µãÐÍ£¨ÊµÊýºÍ¸´Êý£©
(2) ±êÁ¿£¨scalar£©ÀàÐÍ£º°üÀ¨ËãÊõÀàÐͺÍÖ¸ÕëÀàÐÍ
(3) ¼¯ºÏ£¨aggregate£©ÀàÐÍ£º°üÀ¨Êý×éÀàÐͺͽṹÀàÐÍ
ÉÏÃæµÄ (2) ºÍ (3) ÕâÀïûÓÐÓõ½£¬Ö÷ÒªÊÇΪÁËÍêÕûÐԺͷ½±ãÔĶÁ±ê×¼Ìá³ö¡£
2¡¢ÕýʽÌÖÂÛ
(1) ÕûÊýÀàÐÍÌáÉý£¨integer promotions£©
¡¡¡¡ÊÊÓöÔÏó£º±È int ºÍ unsigned int µÍ¼¶µÄÕûÊýÀàÐÍ»òÕß _Bool, int, signed int ºÍ unsigned int µÄ“λÓò”ÀàÐÍ¡£
¡¡¡¡²Ù×÷£ºÈç¹û int ¿ÉÒÔÈÝÄɱ»×ª»»ÀàÐ͵ÄÒ»ÇÐÈ¡Öµ£¬ÔòÌáÉýÖÁ int£¬·ñÔòÌáÉýÖÁ unsigned int¡£
(2) ³£ÓÃËãÊõÀàÐÍת»»£¨Usual arithmetic conversions£©µÄ¹ý³Ì
¡¡¡¡¢ÙÈç¹ûÓи¡µãÊý£¬°´ÕÕ float -> double -> long double µÄ¼¶±ðת»»ÖÁ½Ï¸ßµÄÀàÐÍ¡£
¡¡¡¡¢Ú·ñÔò£¬Ê×ÏÈ×öÕûÊýÀàÐÍÌáÉý£¬È»ºó½«ÌáÉýºóµÄÀàÐÍÔÙ°´ÕûÐͼ¶±ðת»»ÖÁ½Ï¸ßÀàÐÍ¡£
(3) ÒªÇó“³£ÓÃËãÊõÀàÐÍת»»”µÄÇéÐÎ
¡¡¡¡¢Ùµ¥Ä¿ÊýÖµÔËËã·û£¨+, -, ~£©£¬²»°üÀ¨£¨!£©
¡¡¡¡¢Ú³Ë·¨ÐÔÔËËã·û£¨*, /, %£©
¡¡¡¡¢Û¼Ó·¨ÐÔÔËËã·û£¨+, -£©ÖУ¬µ±Á½²àµÄ²Ù×÷Êý¶¼ÊÇËãÊõÀàÐ͵Äʱºò
¡¡¡¡¢


Ïà¹ØÎĵµ£º

C\C++²ËÄñÎÊÌ⼯1

´úÂ룺
#include  <iostream>
using namespace std;
class Clock
{
int hour, minute, second;
public:
   Clock(int h, int m, int s) //¹¹Ô캯Êý¶¨Òå £¬ÎÞ·µ»ØÖµÀàÐÍ
   {     
if(s<0) second=0;
       if (s& ......

C/C++ÖеĽṹÌå¶ÔÆëÎÊÌâ(ÄÚ´æ¶ÔÆë)

ÓÉÓÚ³ÌÐòÔËÐÐʱռÓõÄÄÚ´æ¹ý´ó£¬ËùÒÔÏë°ì·¨¸ø³ÌÐòÊÝÉí¡£
ÔÚµ÷ÊÔÖз¢ÏֽṹÌåÕ¼ÓõÄsize¾¹È»ºÍÔ¤ÏëµÄ²»Ò»Ñù£¬Ô­À´……
¿´¿´ÏÂÃæ½²µÄ°É£¬¿Ï¶¨»á²»Í÷´Ë¿´Å¶£¡
1,±ÈÈç:
struct{
short a1;
short a2;
short a3;
}A;
struct{
long a1;
short a2;
}B;
sizeof(A)=6, sizeof(B)=8,Ϊʲô£¿
×¢£ºsizeof(sho ......

¼òÊöCºÍC++³ÌÐòԱѧϰÀú³Ì

Ò»¼ÒÖ®ÑÔ£¬»¶Ó­ÅÄש¹þ¡£
¡¡¡¡1¡¢¿ÉÒÔ¿¼ÂÇÏÈѧϰC.
¡¡¡¡´ó¶àÊýʱºò£¬ÎÒÃÇѧϰÓïÑÔµÄÄ¿µÄ£¬²»ÊÇΪÁ˳ÉΪһ¸öÓïÑÔר¼Ò£¬¶øÊÇÏ£Íû³ÉΪһ¸ö½â¾öÎÊÌâµÄר¼Ò¡£×öÒ»¸öÓÐÓõijÌÐòÔ±£¬×öÒ»¸ö׬ǮµÄ³ÌÐòÔ±¡£ÎÒÃǵļÛÖµ£¬½«ÌåÏÖÔÚ¿Í»§¼ÛÖµÉÏ£¬¶ø²»ÊÇÓïÑÔдµÃºÃ²»ºÃ¿´¡£
¡¡¡¡C++ÊÇCµÄÒ»¸öÃæÏò¶ÔÏóµÄ½âÊÍ£¬C++ΪCÀ©³äÁË´ó¹æÄ£¹¤³ÌÓ¦ ......

C±ê×¼¿âÔ´Âë½âÆÊ(10)£ºÇøÓòÉèÖú¯Êýlocale.h

    ¹ú¼Ò¡¢ÎÄ»¯ºÍÓïÑÔ¹æÔò¼¯³ÆΪÇøÓòÉèÖã¬locale.hÍ·ÎļþÖж¨ÒåÁËÇøÓòÉèÖÃÏà¹ØµÄº¯Êý¡£setlocaleº¯ÊýÓÃÓÚÉèÖûò·µ»Øµ±Ç°µÄÇøÓòÌØÐÔ£¬localeconvÓÃÓÚ·µ»Øµ±Ç°ÇøÓòÖеÄÊý×ֺͻõ±ÒÐÅÏ¢£¨±£´æÔÚstruct lconv½á¹¹ÊµÀýÖУ©¡£setlocaleµÄµÚÒ»¸öʵ²ÎÖ¸¶¨Òª¸Ä±äµÄÇøÓòÐÐΪÀà±ð£¬Ô¤¶¨ÒåµÄsetlocaleÀà±ðÓУº
 &n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ