Ò»µÀcµÄÃæÊÔÌ⣬´óÊýÏà³Ë
http://www.cnblogs.com/hoodlum1980/archive/2007/08/15/857067.html
Ìâ¸É£ºÊäÈëÁ½¸ö½Ï´óµÄÊý£¬Êä³öÏà³ËµÄ½á¹û¡£
Òâ˼Ҳ¾ÍÊÇÁ½¸öÊýºÜ´ó£¬³¬³öÁËintµÄ´æ´¢·¶Î§¡£
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 100
void GetDigits(int *a,char *s);
void multiply(int *a,int *b,int *c);
main()
{
char s1[N],s2[N];
int i,j,a[N],b[N],c[N*2];
printf("\n input number a: ");
scanf("%s",s1);
printf("\n input number b: ");
scanf("%s",s2);
//°ÑÊäÈëµÄ×Ö·û´®£¬°´Î»´æ·Åµ½Êý×é
GetDigits(a,s1);
GetDigits(b,s2);
multiply(a,b,c);
//ÕÒµ½×î¸ßλ
j=N*2-1;
while(c[j]==0)
j--;
//´òÓ¡¼ÆËã½á¹û
printf("\n %s * %s=",s1,s2);
for(i=j;i>=0;i--)
printf("%d",c[i]);
}
/*°Ñ×Ö·û´®ÐÎʽµÄÊý×Ö°´Î»´æ·Åµ½Êý×é*/
void GetDigits(int *a, char *s)
{
int i;
char digit;
int len=strlen(s);
for(i=0;i<N;i++)
*(a+i)=0;
for(i=0;i<len;i++)
{
digit=*(s+i);
*(a+len-1-i) = digit - '0';
}
}
/*°Ña*bµÄ½á¹û´æ´¢µ½Êý×écÖУ¬°´Î»±íʾ*/
void multiply(int *a,int *b,int *c)
{
int i,j;
//ÏȰѽá¹ûÊý×éÉèÖÃÎ
Ïà¹ØÎĵµ£º
gcc£¬gdbµÄʹÓÃ
×÷Õߣºzccst
ÉÏÖÜÎåÔÚͼÊé¹Ý½èÁËÒ»±¾¡¶LinuxÈí¼þ¹¤³Ìʦ£¨CÓïÑÔ£©ÊµÓý̡̳·£¬ÈÃÎÒÊÕ»ñÁ¼¶à¡£²»½ö½öÊÇÊéÖеÄ֪ʶ£¬»¹ÓжÔ֪ʶÌåϵºÍ¼Ü¹¹ÈÏʶµÄÉîÈë¡£
LinuxÏÂC¿ª·¢£º
1£¬gcc,gdbµÄʹÓá£
2£¬MakefileÎļþµÄ±àд¡£
3£¬ÏµÍ³º¯ÊýµÄʹÓÃ
4£¬Îļþ²Ù×÷
5£¬´®ÐÐͨÐÅ
6£¬½ø³Ì¿ØÖÆ
7£¬½ø³Ì¼ ......
1.½éÉÜÒ»ÏÂSTL£¬Ïêϸ˵Ã÷STLÈçºÎʵÏÖvector.
Answer£º
STL £¨±ê׼ģ°æ¿â£¬Standard Template Library.ËüÓÉÈÝÆ÷Ëã·¨µü´úÆ÷×é³É¡£
STLÓÐÒÔϵÄһЩÓŵ㣺¿ÉÒÔ·½±ãÈÝÒ×µØʵÏÖËÑË÷Êý¾Ý»ò¶ÔÊý¾ÝÅÅÐòµÈһϵÁеÄËã·¨£»µ÷ÊÔ³ÌÐòʱ¸ü¼Ó°²È« ºÍ·½±ã£»¼´Ê¹ÊÇÈËÃÇÓÃSTLÔÚ ......
constÓë#define×î´óµÄ²î±ð£¬ConstÔÚ¶ÑÕ»·ÖÅäÁ˿ռ䣬¶ø#defineÖ»ÊǰѾßÌåÊýÖµÖ±½Ó´«µÝµ½Ä¿±ê±äÁ¿°ÕÁË¡£»òÕß˵£¬constµÄ³£Á¿ÊÇÒ»¸öRun-TimeµÄ¸ÅÄËûÔÚ³ÌÐòÖÐȷȷʵʵµÄ´æÔÚ¿ÉÒÔ±»µ÷Óᢴ«µÝ¡£¶ø#define³£Á¿ÔòÊÇÒ»¸öCompile-Time¸ÅÄËüµÄÉúÃüÖÜÆÚÖ¹ÓÚ±àÒëÆÚ£ºÔÚʵ¼Ê³ÌÐòÖÐËûÖ»ÊÇÒ»¸ö³£Êý¡¢Ò»¸öÃüÁîÖе ......
1,·ÀÖ¹Ò»¸öÍ·Îļþ±»Öظ´°üº¬
#ifndef COMDEF_H
#define COMDEF_H
//Í·ÎļþÄÚÈÝ
#endif
2,ÖØж¨ÒåһЩÀàÐÍ,·ÀÖ¹ÓÉÓÚ¸÷ÖÖƽ̨ºÍ±àÒëÆ÷µÄ²»Í¬,¶ø²úÉúµÄÀàÐÍ×Ö½ÚÊý²îÒì,·½±ãÒÆÖ²¡£
typedef unsigned char boolean; /* Boolean value type. */
typedef ......
char* my_strrev( char* string )
{
char *left, *right, ch;
left = right = string;
while( *right++ != '\0');
right -= 2;
while( left<right )
{
ch = *left;
*left = *right;
*right = ch;
++left; --right;
&n ......