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
Ïà¹ØÎĵµ£º
Q:ʲôÊÇC·ç¸ñת»»£¿Ê²Ã´ÊÇstatic_cast, dynamic_cast ÒÔ¼° reinterpret_cast£¿Çø±ðÊÇʲô£¿ÎªÊ²Ã´Òª×¢Ò⣿
A:ת»»µÄº¬ÒåÊÇͨ¹ý¸Ä±äÒ»¸ö±äÁ¿µÄÀàÐÍΪ±ðµÄÀàÐÍ´Ó¶ø¸Ä±ä¸Ã±äÁ¿µÄ±íʾ·½Ê½¡£ÎªÁËÀàÐÍת»»Ò»¸ö¼òµ¥¶ÔÏóΪÁíÒ»¸ö¶ÔÏóÄã»áʹÓô«Í³µÄÀàÐÍת»»²Ù×÷·û¡£±ÈÈ磬ΪÁËת»»Ò»¸öÀàÐÍΪdouboleµÄ¸¡µãÊýµÄÖ¸Õëµ½ÕûÐÍ£º
......
//ÊäÈëÒ»¸öÊý×飬ÔÙÐÞ¸ÄÕâ¸öÊý×éËùÓÐÔªËØ£¬ÈçºÎʵÏÖ£¿
int main()
{
vector<int> a;
int i(0);
while(cin>>i)
a.push_back(i);
//////////////////////////////////////////////////////Êä³ö½¨Á¢µÄÊý×飺
cout << "µÃµ½µÄÊý×éΪ£º" << ......
1£®ÒÑÖªstrcpy º¯ÊýµÄÔÐÍÊÇ£º
char *strcpy(char *strDest, const char *strSrc);
ÆäÖÐstrDest ÊÇÄ¿µÄ×Ö·û´®£¬strSrc ÊÇÔ´×Ö·û´®¡£²»µ÷ÓÃC++/C µÄ×Ö·û´®¿âº¯Êý£¬Çë±àдº¯Êý strcpy
´ð°¸£º
char *strcpy(char *strDest, const char *strSrc)
{
if ( strDest == NULL || strSrc == NULL)
return NULL ;
if ( strDest ......
C³ÌÐòÖоßÓзḻµÄÊý¾ÝÀàÐÍ£¬°üÀ¨ÉùÃ÷ÖÐÏÔʽ¶¨ÒåµÄÀàÐͺÍÓÃ×ö±í´ïʽÖмäÀàÐ͵ĵ¼³öÀàÐÍ¡£ÀýÈ磬ÏÂÃæµÄ¸³ÖµÓï¾ä°üº¬3 ÖÖ²»Í¬ÀàÐÍ:
int *p, x;
*p = x;
xÊÇÒ»¸ö´æ·ÅÕûÊýµÄµ¥ÔªµÄµØÖ·£¬Òò´ËxµÄµØÖ·µÄÀàÐÍÊÇ£ºÖ¸ÏòÒ»¸öÕûÊýµÄÖ¸Õë¡£xµÄÖµµÄÀàÐÍÊÇÕûÐÍ¡£Í¬Ñù, pµÄ×óÖµµÄÀàÐÍÊÇÖ¸ÏòÒ»¸öÕ ......
cÓëc++ staticº¯ÊýµÄÇø±ð
±¾ÎÄת×Ô£ºhttp://blog.csdn.net/lipps/archive/2007/05/18/1615419.aspx
static¹Ø¼ü×ÖÊÇC, C++Öж¼´æÔڵĹؼü×Ö, ËüÖ÷ÒªÓÐÈýÖÖʹÓ÷½Ê½, ÆäÖÐÇ°Á½ÖÖÖ»Ö¸ÔÚCÓïÑÔÖÐʹÓÃ, µÚÈýÖÖÔÚC++ÖÐʹÓÃ(C,C++ÖоßÌåϸ΢²Ù×÷²»¾¡Ïàͬ, ±¾ÎÄÒÔC++Ϊ׼).
(1)¾Ö²¿¾²Ì¬±äÁ¿
(2)Íⲿ¾²Ì¬±ä ......