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

C %m.ns Êä³ö

#include <stdio.h>
#define N 19
int main()
{
int i;
for (i=0;i<=N;i++)
{
printf("%*.*s%-*.*s\n",N,i<=N/2?i:N-1,"*******************",\
N,i<=N/2?i+1:N-i+1,"*******************");
}
return 0;
}

%m.nsÖмäµÄm.nÊǶÔ%sµÄÐÞÊηû,
   m±íʾ×Ö·û´®ÏÔʾʱµÄ×î´ó¿í¶È,³¬¹ýµÄ»á±»½Øµô,
      n±íʾÏÔʾ×Ö·û´®Öеļ¸¸ö×Ö·û,
   Èç¹ûn<m,ÔòÊý¾Ý¿¿ÓÒ¶ÔÆëÏÔʾ
%-m.ns,ÆäËüºÍÉÏÃæÒ»Ñù,Ö»ÊÇ¿¿×ó¶ÔÆë
%*.*s Á½¸öÐǺÅÀàËÆͨÅä·û,ËüµÄʵ¼ÊÖµÓɺóÃæµÄ²ÎÊý¾ö¶¨
Èçprintf("%*.*s",m,n,"********")¾ÍµÈ¼ÛÓÚ%m.ns
ÏÖÔÚÕâ¶ÎºÃÀí½âÁË
printf("%*.*s%-*.*s\n",N,i<=N/2?i:N-i,"*******************",N,i<=N/2?i+1:N-i+1,"*******************");
½«ÆÁÄ»·Ö³É19+19Á½°ë,Ç°ÃæÒ»°ëÓÉ%*.*s¿ØÖÆ,ºóÃæÒ»°ëÓÉ%-*.*s¿ØÖÆ
µ± i<=N/2ʱ,ÿÐÐÊä³ö i+(i+1)=2i+1 ¸öÐǺÅ
µ± i>N/2 ʱ,ÿÐÐÊä³ö (N-i)+(N-i+1)=2(N-i)+1 ¸öÐǺÅ
ת×Ô £ºhttp://www.oldlinux.org/oldlinux/viewthread.php?tid=9962&extra=page%3D2


Ïà¹ØÎĵµ£º

³¹µ×¸ã¶¨CÖ¸Õ룭º¯ÊýÃûÓ뺯ÊýÖ¸Õë

 º¯ÊýÃûÓ뺯ÊýÖ¸Õë
    º¯Êý´æ·ÅÔÚÄÚ´æµÄ´úÂëÇøÓòÄÚ£¬ËüÃÇͬÑùÓеØÖ·£¬ÎÒÃÇÈçºÎÄÜ»ñµÃº¯ÊýµÄµØÖ·ÄØ£¿
Èç¹ûÎÒÃÇÓÐÒ»¸öint test(int a)µÄº¯Êý£¬ÄÇô£¬ËüµÄµØÖ·¾ÍÊǺ¯ÊýµÄÃû×Ö£¬ÕâÒ»µãÈçͬÊý×éÒ»Ñù£¬Êý×éµÄÃû×Ö¾ÍÊÇÊý×éµÄÆðʼµØÖ·¡£
Ò» ͨ³£µÄº¯Êýµ÷ÓÃ
    Ò»¸öͨ³£µÄº¯Êýµ÷ÓõÄÀý×Ó ......

C´æ´¢ÀàÐͼ°¾²Ì¬¡¢´æ´¢ÀàÐÍÑó½â

 CµÄËÄÖÖ´æ´¢ÀàÏÞ¶¨·û£º
extern:Íⲿ±äÁ¿
static £º¾²Ì¬
register£º´æ´¢Æ÷
auto£º×Ô¶¯¡¡
¾²Ì¬¾Ö²¿±äÁ¿£º
´æ´¢ÇøºÍÈ«¾Ö±äÁ¿ÊÇÒ»ÑùµÄ¡£¾²Ì¬¾Ö²¿ºÍÈ«¾Ö±äÁ¿¼äµÄÖ÷ÒªÇø±ðÊÇ£º¾²Ì¬¾Ö²¿±äÁ¿½ö¶ÔËüÔÚÆäÖÐÉùÃ÷µÄ¿éÊÇ¿ÉÖªµÄ¡£
¾²Ì¬È«¾Ö±äÁ¿£º
¸æËß±àÒëÆ÷´´½¨Ò»¸ö½öÔÚÉùÃ÷ËüµÄÎļþÖпÉÖªµÄÈ«¾Ö±äÁ¿¡£ÕâÒâζ×Å£º¼´Ê¹±äÁ¿Ê ......

extern "C" Ïê½â

 extern "C" Ïê½â
ÔÚC++ÖУ¬ÎªÁËÖ§³ÖÖØÔØ»úÖÆ£¬ÔÚ±àÒëÉú³É»ã±à´úÂëʱ£¬º¯ÊýµÄÃû×ÖÒª¼ÓÈ뺯ÊýµÄ²ÎÊýÀàÐÍ»òÕß·µ»ØÖµÀàÐ͵ÈÐÅÏ¢
ÔÚCÖУ¬ÒòûÓÐÖØÔØ»úÖÆ£¬±àÒëºóµÄ´úÂëÖ»ÊǼòµ¥µÄº¯ÊýÃû×Ö¶øÒÑ£¬²»¼ÓÈëÆäËûµÄÐÅÏ¢ 
1. ²»¼ÓÈëextern "C"
testexternc.cpp
int mytest(void)
{
int a=10,b=20;
int c=a+b;
ret ......

ŪÁË°ëÒ¹¾ÍûÏëÃ÷°×£¬µô½øCÏÝÚåÁË£¬555

 
//ÊäÈëÒ»¸öÊý×飬ÔÙÐÞ¸ÄÕâ¸öÊý×éËùÓÐÔªËØ£¬ÈçºÎʵÏÖ£¿
int main()
{
 vector<int> a;
 int i(0);
 while(cin>>i)
  a.push_back(i);
 //////////////////////////////////////////////////////Êä³ö½¨Á¢µÄÊý×飺
 cout << "µÃµ½µÄÊý×éΪ£º" << ......

Éú²úÕß Ïû·ÑÕßÎÊÌâʵÏÖ (linuxÏÂCÓïÑÔ)

²Ù×÷ϵͳµÄÒ»¸ö¾­µäÎÊÌâÊÇ"Éú²úÕß-Ïû·ÑÕß"ÎÊÌâ, ÕâÉ漰ͬ²½ÐźÅÁ¿ºÍ»¥³âÐźÅÁ¿µÄÓ¦ÓÃ, ÔÚÕâÀï,ÎÒÓÃÏ̵߳Äͬ²½ºÍ»¥³âÀ´ÊµÏÖ.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <semaphore.h>
#define N 2   // Ïû·ÑÕß» ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ