c ±ê×¼ÊäÈëÊä³ö
1.1.1 ¸ñʽ»¯ÊäÈëÊä³öº¯Êý
Turbo C2.0 ±ê×¼¿âÌṩÁËÁ½¸ö¿ØÖÆ̨¸ñʽ»¯ÊäÈë¡¢ Êä³öº¯Êýprintf( ) ºÍ
scanf(), ÕâÁ½¸öº¯Êý¿ÉÒÔÔÚ±ê×¼ÊäÈëÊä³öÉ豸ÉÏÒÔ¸÷ÖÖ²»Í¬µÄ¸ñʽ¶ÁдÊý¾Ý¡£
printf()º¯ÊýÓÃÀ´Ïò±ê×¼Êä³öÉ豸(ÆÁÄ»)дÊý¾Ý; scanf() º¯ÊýÓÃÀ´´Ó±ê×¼ÊäÈë
É豸(¼üÅÌ)É϶ÁÊý¾Ý¡£ÏÂÃæÏêϸ½éÉÜÕâÁ½¸öº¯ÊýµÄÓ÷¨¡£
Ò»¡¢printf()º¯Êý
printf()º¯ÊýÊǸñʽ»¯Êä³öº¯Êý, Ò»°ãÓÃÓÚÏò±ê×¼Êä³öÉ豸°´¹æ¶¨¸ñʽÊä³ö
ÐÅÏ¢¡£ÔÚ±àд³ÌÐòʱ¾³£»áÓõ½´Ëº¯Êý¡£printf()º¯ÊýµÄµ÷ÓøñʽΪ:
printf("<¸ñʽ»¯×Ö·û´®>", <²ÎÁ¿±í>);
ÆäÖиñʽ»¯×Ö·û´®°üÀ¨Á½²¿·ÖÄÚÈÝ: Ò»²¿·ÖÊÇÕý³£×Ö·û, ÕâЩ×Ö·û½«°´Ô
ÑùÊä³ö; ÁíÒ»²¿·ÖÊǸñʽ»¯¹æ¶¨×Ö·û, ÒÔ"%"¿ªÊ¼, ºó¸úÒ»¸ö»ò¼¸¸ö¹æ¶¨×Ö·û,
ÓÃÀ´È·¶¨Êä³öÄÚÈݸñʽ¡£
²ÎÁ¿±íÊÇÐèÒªÊä³öµÄһϵÁвÎÊý, Æä¸öÊý±ØÐëÓë¸ñʽ»¯×Ö·û´®Ëù˵Ã÷µÄÊä³ö
²ÎÊý¸öÊýÒ»Ñù¶à, ¸÷²ÎÊýÖ®¼äÓÃ","·Ö¿ª, ÇÒ˳ÐòÒ»Ò»¶ÔÓ¦, ·ñÔò½«»á³öÏÖÒâÏë
²»µ½µÄ´íÎó¡£
1. ¸ñʽ»¯¹æ¶¨·û
Turbo C2.0ÌṩµÄ¸ñʽ»¯¹æ¶¨·ûÈçÏÂ:
©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥
·ûºÅ ×÷ÓÃ
——————————————————————————
%d Ê®½øÖÆÓзûºÅÕûÊý
%u Ê®½øÖÆÎÞ·ûºÅÕûÊý
%f ¸¡µãÊý
%s ×Ö·û´®
%c µ¥¸ö×Ö·û
%p Ö¸ÕëµÄÖµ
%e Ö¸ÊýÐÎʽµÄ¸¡µãÊý
%x, %X ÎÞ·ûºÅÒÔÊ®Áù½øÖƱíʾµÄÕûÊý
%0 ÎÞ·ûºÅÒ԰˽øÖƱíʾµÄÕûÊý
%g ×Ô¶¯Ñ¡ÔñºÏÊʵıíʾ·¨
©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥©¥
˵Ã÷:
(1). ¿ÉÒÔÔÚ"%"ºÍ×Öĸ֮¼ä²å½øÊý×Ö±íʾ×î´ó³¡¿í¡£
ÀýÈç: %3d ±íʾÊä³ö3λÕûÐÍÊý, ²»¹»3λÓÒ¶ÔÆë¡£
%9.2f ±íʾÊä³ö³¡¿íΪ9µÄ¸¡µãÊý, ÆäÖÐСÊýλΪ2, ÕûÊýλΪ6,
СÊýµãռһλ, ²»¹»9λÓÒ¶ÔÆë¡£
%8s ±íʾÊä³ö8¸ö×Ö·ûµÄ×Ö·û´®, ²»¹»8¸ö×Ö·ûÓÒ¶ÔÆë¡£
Èç¹û×Ö·û´®µÄ³¤¶È¡¢»òÕûÐÍÊýλÊý³¬¹ý˵Ã÷µÄ³¡¿í, ½«°´Æäʵ¼Ê³¤¶ÈÊä³ö¡£
µ«¶Ô¸¡µãÊý, ÈôÕûÊý²¿·ÖλÊý³¬¹ýÁË˵Ã÷µÄÕûÊýλ¿í¶È, ½«°´Êµ¼ÊÕûÊýλÊä³ö;
ÈôСÊý²¿·ÖλÊý³¬¹ýÁË˵Ã÷µÄСÊýλ¿í¶È, Ôò°´ËµÃ÷µÄ¿í¶ÈÒÔËÄÉáÎåÈëÊä³ö¡£
ÁíÍâ, ÈôÏëÔÚÊä³öֵǰ¼ÓһЩ0, ¾ÍÓ¦ÔÚ³¡¿íÏîÇ°¼Ó¸ö0¡£
ÀýÈç: %04d ±íʾÔÚÊä³öÒ»¸öСÓÚ4λµÄÊýֵʱ, ½«ÔÚÇ°Ãæ²¹0ʹÆä×Ü¿í¶È
Ϊ4λ¡£
Èç¹ûÓø¡µãÊý±íʾ×Ö·û»òÕûÐÍÁ
Ïà¹ØÎĵµ£º
Delphi Óë C/C++ Êý¾ÝÀàÐͶÔÕÕ±í
DelphiÊý¾ÝÀàÐÍC/C++
ShorInt
8λÓзûºÅÕûÊý
char
Byte
8λÎÞ·ûºÅÕûÊý
BYTE,unsigned short
SmallInt
16λÓзûºÅÕûÊý
short
Word
16λÎÞ·ûºÅÕûÊý
unsigned short
Integer,LongInt
32λÓзûºÅÕûÊý
int,long
Cardinal,LongWord/DWORD
32λÎÞ·ûºÅÕûÊý
unsigned long
Int6 ......
¹þ¹þ£¡ÓÐÐÒÔÚijÍøÕ¾·¢ÏÖÕâƪÎÄÕ£¬¶Á°Õ£¬¾õµÃÂùÓеÀÀí£¬·¢À´´ó¼ÒÒ»Æð¹²ÃãÖ®
×ÜÊDZ»Í¬Ñ§ÃÇÎʵ½£¬ÈçºÎѧϰCºÍC++²Å²»Ã£È»£¬²Å²»ÊÇÂÒѧ£¬ÏëÁËһϣ¬ÕâÀï¸ø³öÒ»¸ö×ܵĻظ´¡£
¡¡¡¡Ò»¼ÒÖ®ÑÔ£¬»¶ÓÅÄש¹þ¡£
¡¡¡¡1¡¢¿ÉÒÔ¿¼ÂÇÏÈѧϰC.
¡¡¡¡´ó¶àÊýʱºò£¬ÎÒÃÇѧϰÓïÑÔµÄÄ¿µÄ£¬²»ÊÇΪÁ˳ÉΪһ¸öÓïÑÔר¼Ò£¬¶øÊÇÏ£Íû ......
Â¥Ö÷·¢±íÓÚ£º2009-07-24 10:11:03ÊÇÕâÑùµÄ,È¥Ò»¼Ò¹«Ë¾ÃæÊÔ,Óöµ½ÁËÒ»µÀcÓïÑÔµÄÌâ,¸öÈË
¸Ð¾õºÜ¹Ö,ÒÔǰû¼û¹ýÀàËƵÄ,È»ºóÖ÷¿¼¹Ù˵ÕâÊǹØÓÚCÓïÑÔÇ¿ÈõÀàÐÍת»»Ê²Ã´µÄ,ÎҸоõËû
×Ô¼º¶¼²»ÍêÈ«Çå³þ,È»ºó»ØÀ´ÔÚÍøÉϲ鵽ÕâÊÇÓ¢¹ú½£ÇÅ´óѧÍøÉϳöµÄ¼ÆËã»úÌâ :
#include <stdio.h>
#define init_employee(X,Y) {(X),(Y),wage ......
Õ⼸ÌìÓÉÓÚÒª¶ÁÈ¡½Ï´óµÄÎı¾Îļþ£¬ËùÒԾͱȽÏÁËÒ»ÏÂÁ½ÕßÖ®¼äµÄЧÂÊÎÊÌâ¡£ ËùÒª¶ÁÈ¡µÄÎı¾Îļþ½á¹¹ÎªÃ¿ÐÐÓÉ5¸öÊý×é³É£¬int int int float int£¬²âÊÔµÄÎļþÓÐ33WÐУ¬´óСΪ9M¡£ÏÖÔÚÒª½«Æä¶Áµ½Ò»¸öcube½á¹¹ÌåÀïÃæÈ¥£¬½á¹¹ÌåÓÐ5¸ö³ÉÔ±±äÁ¿ÓëÖ®¶ÔÓ¦¡£ Á½ÖÖ²Ù×÷µÄ´úÂëÈçÏ start = clock();
......