¸ñʽÊä³ö:
printf(¸ñʽ¿ØÖÆ, Êä³ö±íÁÐ);
%d Ê®½øÖÆÊý %md mΪָ¶¨µÄ¿í¶È ÈôÊý¾ÝλÊýСÓÚm,Ôò×ó¶Ë²¹ÒÔ¿Õ¸ñ;Èô´óÓÚm,Ôò°´Êµ¼ÊλÊýÊä³ö
%ld ³¤ÕûÐÍÊý¾Ý %mld Ö¸¶¨×ֶοí¶È
%o °Ë½øÖÆÕûÊýÐÎʽ %mo
%x Ê®Áù½øÖÆÕûÊýÐÎʽ %mx
%u unsignedÐÍÊý¾Ý,ËüÒ²¿ÉÓÃ%o»ò%x¸ñʽÊä³ö
%c Ò»¸ö×Ö·û %mc
%s ×Ö·û´® Óм¸ÖÖÓ÷¨
1.%s
printf("%s", "China");
Êä³ö China
2.%ms ¿ØÖÆΪmÁÐ Èô´®³¤Ð¡ÓÚm, Ôò×󲹿ոñ,´óÓÚÔòÍ»ÆÆmÏÞÖÆ,½«×Ö·û´®ÍêÈ«Êä³ö
3.%-ms Èô´®³¤Ð¡ÓÚm, ÔòÓÒ²¹¿Õ¸ñ(¾Ó×ó)
4.%m.ns Êä³öÕ¼mÁÐ,È¡×Ö·û´®×ó¶Ën¸ö×Ö·û.Õân¸ö×Ö·ûÊä³öÔÚmÁеÄÓÒ²à,×󲹿ոñ
5.%-m.ns m.nͬÉÏ,Õân¸ö×Ö·ûÊä³öÔÚmÁеÄ×ó²à,ÓÒ²¹¿Õ¸ñ.Èôn>m,Ôòm×Ô¶¯È¡nÖµ,±£Ö¤n¸ö×Ö·ûÕý³£Êä³ö
%f Êä³öʵÊý(°üÀ¨µ¥.Ë«¾«¶È),ÒÔСÊýÐÎʽÊä³ö
1.%f Êä³öÈ«²¿ÕûÊý²¿·Ö,Êä³ö6λСÊý
2.%m.nf Ö¸¶¨Êä³öµÄÊý¾Ý¹²Õ¼mÁÐ,ÆäÖÐÓÐnλСÊý.ÈôÊýÖµ³¤¶ÈСÓÚm,Ôò×ó¶Ë²¹¿Õ¸ñ
3.%-m.nf Ö¸¶¨Êä³öµÄÊý¾Ý¹²Õ¼mÁÐ,ÆäÖÐÓÐnλСÊý.ÈôÊýÖµ³¤¶ÈСÓÚm,ÔòÓҶ˲¹¿Õ¸ñ
%e ÒÔÖ¸ÊýÐÎʽÊä³öʵÊý
1.%e ²»Ö¸¶¨Êä³öÊý¾ÝËùÕ¼µÄ¿í¶ÈºÍÊý×Ö²¿·ÖµÄСÊýÊýλ,ÊýÖµ°´¹æ·¶»¯Êä³ö
2.%m.ne ºÍ %-m.ne Êä³öÕ¼mÁÐ,nÖ¸Êä³öµÄÊý¾ÝµÄСÊý²¿·Ö(βÊý)µÄСÊýÊýλ,-ͬÉÏ
%g Êä³öʵÊý,¸ù¾ÝÊýÖµ´óС,×Ô¶¯Ñ¡Ôñf¸ñʽ»òÕße¸ñʽ(Ñ¡ÔñÊä³ö¿í¶ÈСµÄ),ÇÒ²»Êä³öÎÞÒâÒåµÄÁã
¸ñʽ¿ØÖÆÖпÉÒÔ°üº¬×ªÒå×Ö·û,Èç'\n' '\t' '\b' '\r'
Êä³ö%µÄ·½·¨ printf("%f%%", 1.0/3) Êä³ö: 0.333333%
¸ñʽÊäÈë
scanf(¸ñʽ¿ØÖÆ, µØÖ·±íÁÐ) sscanf
ÀàËÆprintf .ÒÔÀý³Ì½âÊÍ
1. scanf("%3d%3d", &a, &b); //ÁÐÊý½ØÈ¡Êý¾Ý
input -> 123456
then -> a = 123 b = 456
2. scanf("%2d %*3d %2d", &a, &b) //*±íʾÌø¹ýÁÐÊý¶ÁÈ¡Êý¾Ý
input -> 12 345 67
then -> a = 12 b = 67
3. scanf("%d, %d", &a, &b)
input -> 1, 4 //ÔÚ¸ñʽ¿ØÖÆÖÐ,Èç¹ûÓзǸñʽ˵Ã÷ÍâµÄ×Ö·û,Ó¦¸ÃÔÚÊäÈëʱÔÚ¶ÔӦλÖÃÊäÈë¸Ã×Ö·û
scanf("%d %d", &a, &b) //ÊäÈëʱ,Á½Êý¾ÝÓ¦Óв»ÉÙÓÚ¸ñʽ¿ØÖÆÖеĿոñ
scanf(&quo
Ö¸ÕëÊÇC/C++ÓïÑÔµÄÌØÉ«£¬¶øÊý×éÃûÓëÖ¸ÕëÓÐÌ«¶àµÄÏàËÆ£¬ÉõÖÁºÜ¶àʱºò£¬Êý×éÃû¿ÉÒÔ×÷ΪָÕëʹÓá£ÓÚÊǺõ£¬ºÜ¶à³ÌÐòÉè¼ÆÕ߾ͱ»¸ãºýÍ¿ÁË¡£¶øÐí¶àµÄ´óѧÀÏʦ£¬ËûÃÇÔÚCÓïÑԵĽÌѧ¹ý³ÌÖÐÒ²´íÎóµÃ¸øѧÉú½²½â£º"Êý×éÃû¾ÍÊÇÖ¸Õë"¡£ºÜÐÒÔË£¬ÎҵĴóѧÀÏʦ¾ÍÊÇÆäÖÐÖ®Ò»¡£Ê±ÖÁ½ñÈÕ£¬ÎÒÈÕ¸´Ò»ÈյؽøÐÐ×ÅC/C++ÏîÄ¿µÄ¿ª·¢£¬¶øÉí±ß»¹Ò»Ö±³äÂúÕ ......
Ôø¾Åöµ½¹ýÈÃÄãÃԻ󲻽⡢ÀàËÆÓÚint * (* (*fp1) (int) ) [10];ÕâÑùµÄ±äÁ¿ÉùÃ÷Â𣿱¾ÎĽ«ÓÉÒ×µ½ÄÑ£¬Ò»²½Ò»²½½Ì»áÄãÈçºÎÀí½âÕâÖÖ¸´ÔÓµÄC/C++ÉùÃ÷¡£
¡¡¡¡ÎÒÃǽ«´ÓÿÌ춼ÄÜÅöµ½µÄ½Ï¼òµ¥µÄÉùÃ÷ÈëÊÖ£¬È»ºóÖð²½¼ÓÈëconstÐÞÊηûºÍtypedef£¬»¹Óк¯ÊýÖ¸Õ룬×îºó½éÉÜÒ»¸öÄܹ»ÈÃÄã׼ȷµØÀí½âÈκÎC/C++ÉùÃ÷µÄ“ÓÒ×ó·¨Ôò”¡£ ......