返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. double test(double a,double b)
  5. {
  6.         return a*b;
  7. }
  8. int main()
  9. {
  10.         int a=0,b=0;
  11.         cout<<"請輸入第一個數字"<<endl;
  12.         cin>>a;
  13.         cout<<"請輸入第二個數字"<<endl;
  14.         cin>>b;
  15.         for(int i=1;i<=a;i++)
  16.         {
  17.                 for(int j=1;j<=b;j++)
  18.                 {
  19.                   cout<<i<<"*"<<j<<"="<<test(a,b)<<"\t";       
  20.                 }
  21.         }
  22.         system("pause");
  23.         return 0;
  24. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. void total(int a,int b)
  5. {
  6.     for(int i=1;i<=a;i++)
  7.     {
  8.             for(int j=1;j<=b;j++)
  9.             {
  10.                     cout<<i<<"*"<<j<<"="<<i*j<<"\t";
  11.             }
  12.     }
  13.     cout<<endl;
  14. }
  15. int main()
  16. {
  17.     int a=0,b=0;
  18.     cout<<"請輸入兩個數字"<<endl;
  19.     cin>>a;
  20.     cin>>b;
  21.     total(a,b);
  22.     system("pause");
  23.     return 0;
  24. }
複製代碼

TOP

返回列表