返回列表 發帖

小星星 1

試運用巢狀迴圈完成以下圖
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    for(______________)
  7.    {
  8.        for(______________)
  9.        {
  10.             cout<<"*";
  11.        }
  12.        cout<<endl;
  13.    }
  14.    system("pause");
  15.    return 0;
  16. }
複製代碼
案:
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

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

TOP

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

TOP

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

TOP

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

TOP

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

TOP

返回列表