Advertisement
heranchris0430

位數相乘

Apr 19th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <stdlib.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     unsigned long en, m[10] = { 0 }, n[99999] = { 0 }, a[99999] = { 0 };
  10.     while (1) {
  11.         cin >> en;
  12.  
  13.         for (int k = 0; k < en; k++) {
  14.             cin >> a[k];
  15.         }
  16.  
  17.         for (int t = 0; t < 100000; t++) {
  18.             n[t] = 1;
  19.         }
  20.  
  21.         for (int bc = 0; bc < en; bc++) {
  22.             for (int x = 0; x < 10; x++) {
  23.                 m[x] = a[bc] % 10;
  24.                 a[bc] /= 10;
  25.                 n[bc] *= m[x];
  26.                 if (a[bc] == 0) {
  27.                     goto end;
  28.                 }
  29.             }
  30.         end:
  31.             cout << " ";
  32.             m[10] = { 0 };
  33.         }
  34.  
  35.         cout << endl;
  36.  
  37.         for (int k = 0 ; k < en; k++) {
  38.             cout << n[k] << endl;
  39.         }
  40.         system("PAUSE");
  41.         system("CLS");
  42.     }
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement