返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;


  4. void say_hello()
  5. {
  6.         cout<<"*======================*"<<endl;
  7.         cout<<"*歡迎使用璽安小星星軟體*"<<endl;       
  8.         cout<<"*======================*"<<endl;
  9. }

  10. void triangle1()
  11. {
  12.         cout<<"L形三角形"<<endl;
  13.         for(int i=1; i<=5; i++)
  14.         {
  15.                 for(int j=1; j<=i; j++)
  16.                 {
  17.                         cout<<"*";
  18.                 }
  19.                 cout<<endl;
  20.         }       
  21.        
  22. }

  23. int main()
  24. {
  25.         while(true)
  26.         {
  27.                 say_hello();
  28.                 triangle1();
  29.                 system("pause");       
  30.         }       
  31.         return 0;
  32. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;


  4. void say_hello()
  5. {
  6.         cout<<"*======================*"<<endl;
  7.         cout<<"*歡迎使用璽安小星星軟體*"<<endl;        
  8.         cout<<"*======================*"<<endl;
  9. }

  10. void triangle1()
  11. {
  12.         cout<<"L形三角形"<<endl;
  13.         for(int i=1; i<=5; i++)
  14.         {
  15.                 for(int j=1; j<=i; j++)
  16.                 {
  17.                         cout<<"*";
  18.                 }
  19.                 cout<<endl;
  20.         }        
  21. }

  22. void triangle2()
  23. {
  24.     cout<<"倒L形三角形"<<endl;
  25.     for(int i = 1; i <= 5; i++)
  26.         {
  27.                 for(int k = 1; k <= 5 - i; k++)
  28.                 {
  29.                         cout<<" ";
  30.                 }
  31.                 for(int j = 1; j <= i; j++)
  32.                 {
  33.                         cout<<"*";
  34.                 }
  35.                 cout<<endl;
  36.         }  

  37. void triangle3()
  38. {
  39.     cout<<"等腰三角形"<<endl;   
  40.     for(int i = 1; i <= 5; i++)
  41.     {
  42.          for(int j = 1; j <= 5 - i; j++)
  43.          {
  44.          cout << " ";
  45.          }
  46.          for(int k = 1; k <= (i * 2) - 1; k++)
  47.          {
  48.          cout << "*";
  49.          }
  50.          cout << endl;
  51.     }
  52. }

  53. int main()
  54. {
  55.         while(true)
  56.         {
  57.                 say_hello();
  58.                 triangle1();
  59.                 triangle2();
  60.                 triangle3();
  61.                 system("pause");        
  62.         }        
  63.         return 0;
  64. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. void say_hello()
  5. {
  6.         cout<<"*======================*"<<endl;
  7.         cout<<"*歡迎使用璽安小星星軟體*"<<endl;        
  8.         cout<<"*======================*"<<endl;
  9. }
  10. void triangle1()
  11. {
  12.         cout<<"L形三角形"<<endl;
  13.         for(int i=1; i<=5; i++)
  14.         {
  15.                 for(int j=1; j<=i; j++)
  16.                 {
  17.                         cout<<"*";
  18.                 }
  19.                 cout<<endl;
  20.         }        
  21. }

  22. void triangle2()
  23. {
  24.     cout<<"倒L形三角形"<<endl;
  25.     for(int i = 1; i <= 5; i++)
  26.     {
  27.             for(int k = 1; k <= 5 - i; k++)
  28.             {
  29.                     cout<<" ";
  30.             }
  31.             for(int j = 1; j <= i; j++)
  32.             {
  33.                     cout<<"*";
  34.             }
  35.             cout<<endl;
  36.     }
  37. }
  38.           
  39. void triangle3()
  40. {
  41.     cout<<"等腰三角形"<<endl;   
  42.     for(int i = 1; i <= 5; i++)
  43.     {
  44.          for(int j = 1; j <= 5 - i; j++)
  45.          {
  46.          cout << " ";
  47.          }
  48.          for(int k = 1; k <= (i * 2) - 1; k++)
  49.          {
  50.          cout << "*";
  51.          }
  52.          cout << endl;
  53.     }
  54. }
  55. void triangle4()
  56. {
  57.         cout << "垂直翻轉L形三角形" <<endl;
  58.         for(int i = 5; i >= 1; i--)
  59.         {
  60.                 for(int j = 1; j <= i; j++)
  61.                 {
  62.                         cout << "*";
  63.                 }
  64.                 cout <<endl;
  65.         }
  66. }
  67. void triangle5()
  68. {
  69.     cout << "垂直翻轉等腰三角形" << endl;   
  70.     for(int i = 5; i >= 1; i--)
  71.     {
  72.          for(int j = 1; j <= 5 - i; j++)
  73.          {
  74.          cout << " ";
  75.          }
  76.          for(int k = 1; k <= (i * 2) - 1; k++)
  77.          {
  78.          cout << "*";
  79.          }
  80.          cout << endl;
  81.     }
  82. }
  83. void triangle6()
  84. {
  85.     cout << "菱形" << endl;   
  86.     for(int i = 1; i <= 3; i++)
  87.     {
  88.          cout << " ";
  89.          for(int j = 1; j <= 3 - i; j++)
  90.          {
  91.          cout << " ";
  92.          }
  93.          for(int k = 1; k <= (i * 2) - 1; k++)
  94.          {
  95.          cout << "*";
  96.          }
  97.          cout << endl;
  98.     }
  99.     for(int i = 4; i >= 1; i--)
  100.     {
  101.          for(int j = 1; j <= 4 - i; j++)
  102.          {
  103.          cout << " ";
  104.          }
  105.          for(int k = 1; k <= (i * 2) - 1; k++)
  106.          {
  107.          cout << "*";
  108.          }
  109.          cout << endl;
  110.     }                                             
  111. }
  112. int main()
  113. {
  114.         while(true)
  115.         {
  116.                 say_hello();
  117.                 triangle1();
  118.                 triangle2();
  119.                 triangle3();
  120.                 triangle4();
  121.                 triangle5();
  122.                 triangle6();
  123.                 system("pause");        
  124.         }        
  125.         return 0;
  126. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. void say_hello()
  5. {
  6.         cout<<"*======================*"<<endl;
  7.         cout<<"*歡迎使用璽安小星星軟體*"<<endl;        
  8.         cout<<"*======================*"<<endl;
  9. }
  10. void triangle1()
  11. {
  12.         cout<<"L形三角形"<<endl;
  13.         for(int i=1; i<=5; i++)
  14.         {
  15.                 for(int j=1; j<=i; j++)
  16.                 {
  17.                         cout<<"*";
  18.                 }
  19.                 cout<<endl;
  20.         }        
  21. }

  22. void triangle2()
  23. {
  24.     cout<<"倒L形三角形"<<endl;
  25.     for(int i = 1; i <= 5; i++)
  26.     {
  27.             for(int k = 1; k <= 5 - i; k++)
  28.             {
  29.                     cout<<" ";
  30.             }
  31.             for(int j = 1; j <= i; j++)
  32.             {
  33.                     cout<<"*";
  34.             }
  35.             cout<<endl;
  36.     }
  37. }
  38.          
  39. void triangle3()
  40. {
  41.     cout<<"等腰三角形"<<endl;   
  42.     for(int i = 1; i <= 5; i++)
  43.     {
  44.          for(int j = 1; j <= 5 - i; j++)
  45.          {
  46.          cout << " ";
  47.          }
  48.          for(int k = 1; k <= (i * 2) - 1; k++)
  49.          {
  50.          cout << "*";
  51.          }
  52.          cout << endl;
  53.     }
  54. }
  55. void triangle4()
  56. {
  57.         cout << "垂直翻轉L形三角形" <<endl;
  58.         for(int i = 5; i >= 1; i--)
  59.         {
  60.                 for(int j = 1; j <= i; j++)
  61.                 {
  62.                         cout << "*";
  63.                 }
  64.                 cout <<endl;
  65.         }
  66. }
  67. void triangle5()
  68. {
  69.     cout << "垂直翻轉等腰三角形" << endl;   
  70.     for(int i = 5; i >= 1; i--)
  71.     {
  72.          for(int j = 1; j <= 5 - i; j++)
  73.          {
  74.          cout << " ";
  75.          }
  76.          for(int k = 1; k <= (i * 2) - 1; k++)
  77.          {
  78.          cout << "*";
  79.          }
  80.          cout << endl;
  81.     }
  82. }
  83. void triangle6()
  84. {
  85.     cout << "菱形" << endl;   
  86.     for(int i = 1; i <= 3; i++)
  87.     {
  88.          cout << " ";
  89.          for(int j = 1; j <= 3 - i; j++)
  90.          {
  91.          cout << " ";
  92.          }
  93.          for(int k = 1; k <= (i * 2) - 1; k++)
  94.          {
  95.          cout << "*";
  96.          }
  97.          cout << endl;
  98.     }
  99.     for(int i = 4; i >= 1; i--)
  100.     {
  101.          for(int j = 1; j <= 4 - i; j++)
  102.          {
  103.          cout << " ";
  104.          }
  105.          for(int k = 1; k <= (i * 2) - 1; k++)
  106.          {
  107.          cout << "*";
  108.          }
  109.          cout << endl;
  110.     }                                             
  111. }
  112. int main()
  113. {
  114.     while(true)
  115.     {
  116.             int a;
  117.         system("cls");       
  118.         say_hello();
  119.         cout << "請選擇要顯示的三角形" << endl;
  120.         cout << "1)L形三角形" <<endl;
  121.         cout << "2)倒L形三角形" <<endl;
  122.         cout << "3)等腰三角形" <<endl;
  123.         cout << "4)垂直翻轉L形三角形" << endl;
  124.         cout << "4)垂直翻轉等腰三角形" <<endl;
  125.         cout << "5)菱形" << endl;
  126.         cout << "請選擇" << endl;
  127.                 cin >> a;
  128.                
  129.                 switch (a)
  130.                 {
  131.                         case 1:
  132.                                 triangle1();
  133.                                 break;
  134.                         case 2:
  135.                                 triangle2();
  136.                                 break;
  137.                         case 3:
  138.                                 triangle3();
  139.                                 break;
  140.                         case 4:
  141.                                 triangle4();
  142.                                 break;
  143.                         case 5:
  144.                                 triangle5();
  145.                                 break;
  146.                         case 6:
  147.                                 triangle6();
  148.                                 break;
  149.                 }
  150.         system("pause");        
  151.     }        
  152.     return 0;
  153. }
複製代碼

TOP

返回列表