A. c語言實現各位數字的相乘
C語言用這個,C++用樓上那個。
#include<stdio.h>
int main()
{
    int n, i;
     char c;
     printf("\n Please input an integer number (decimal), this program will get the proct of every digit of the number. End the input with \"Enter\".\n ");
     n=1;
     c=getchar();
    while(c !='\n')
    {  if(c<'0' || c>'9')
          {  printf("\n Error! The input is incorrect. The character input just now is not a digital. Finish.\n",n);
              return 0;
            }
         if(c=='0')
          {  printf("\n  The character input just now is \"0\", the proct is \"0\". No need to input more.\n Finish.\n",n);
              return 0;
            }
         n*=(int)(c-48);
         c=getchar();
      }
    printf("\n  The proct is \"%d\". \n Finish.\n", n);
    return 1;
}
B. c語言大整數乘法
scanf("%s%s",&a,&b);
我學兩天C直接就學JAVA了。
說下我的看法吧。
a[i]-'0'
//a[i]比如i為10你裡面都沒賦值這個值我覺得是隨機的,因為操作系統與編譯器沒必要對於所引用的地址進行操作。
而且減'0'雖然'0'可以轉化成asc2碼,但是這樣做應該不行吧。。。
或者相乘超過了2的8次(c[i+j+1]不能存放這么多位,地址溢出)。
