返回列表 發帖

小星星 4

利用巢狀迴圈, 試做一個長為10顆*, 高為4顆*, 之平行四邊形, 排列如下圖:
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     for(____________)
  7.     {
  8.           for(____________)
  9.           {
  10.               cout<<" ";
  11.           }
  12.           for(____________)
  13.           {
  14.               cout<<"*";
  15.           }
  16.     cout<<endl;      
  17.     }
  18.     system("pause");
  19.     return 0;
  20. }
複製代碼
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
  for(int x=0;x<=3;x++)
  {
       for(int y=0;y<0+x;y++)
       {
            cout<<" ";   
       }
       for(int z=0;z<=10;z++)
       {
            cout<<"*";   
       }
       cout<<endl;         
  }      
  system ("pause");
  return 0;   
}

TOP

  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.   for(int x=0; x<0+X; x++)
  7.   {
  8.        for(int s=0;s<0+X s++)
  9.        {
  10.             cout<<" ";   
  11.        }
  12.        for(int j=0;j<0+X j++)
  13.        {
  14.             cout<<"*";   
  15.        }
  16.        cout<<endl;         
  17.   }      
  18.   system ("pause");
  19.   return 0;   
  20. }
複製代碼

TOP

  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.   for(int x=0;x<=3;x++)
  7.   {
  8.        for(int y=0;y<0+x;y++)
  9.        {
  10.             cout<<" ";   
  11.        }
  12.        for(int z=0;z<=10;z++)
  13.        {
  14.             cout<<"*";   
  15.        }
  16.        cout<<endl;         
  17.   }      
  18.   system ("pause");
  19.   return 0;   
  20. }
複製代碼

TOP

#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
  for(_____________)
  {
       for(_____________)
       {
            cout<<" ";   
       }
       for(_____________)
       {
            cout<<"*";   
       }
       cout<<endl;         
  }      
  system ("pause");
  return 0;   
}

TOP

返回列表