#1542. 循环语句-选择题2
循环语句-选择题2
1、以下选项中不会一直输出“*”的是( )。 {{ select(1) }}
- 
for (int i = 0; i < 0; i++) { cout <<“*"; } - 
while (-1) { cout << '*'; } - 
for (int i = 0; ;i++) { cout << '*'; } - 
do { cout << '*'; } while(true); 
2、执行以下代码,输出几列“*”?( )
for(int i = 0; i < 4; i++)
{
    for(int j = 0; j < 5; j++)
        cout << "*";
    cout << endl;
}
{{ select(2) }}
- 4
 - 5
 - 6
 - 7
 
3、以下选项中,可以输出如下图案的是( )。
******
******
******
******
******
{{ select(3) }}
- 
int n = 5, m = 6; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) cout << "*"; } - 
int n = 5, m = 6; while(n > 0) { for(int j = 0; j < m; j++) cout << "*"; n--; cout << endl; } - 
int n = 5, m = 6; for(int i = 1; i <= n; i++) { for(int j = 0; j < m; j++) { cout << "*" << endl; } } - 
int n = 5, m = 6; while(m > 0) { for(int j = 0; j < n; j++) cout << "*"; m--; cout << endl; } 
4、输出如下图案(第一行星号前面有 4 个空格,后面每行星号前面的空格数比前一行少一个),下列代码中的下划线处应填写的语句是( )。
    *
   *
  *
 *
*
int n = 5;
for (int i = 1; i <= n; i++)
{
    for (int j = 1; j <= n; j++)
    {
        —————————————
            cout << '*';
        else
            cout << ' ';//1 个空格
    }
    cout << endl;
}
{{ select(4) }}
- if (i == j)
 - if (i == j + 1)
 - if (i + j == n + 1)
 - if (i + j == n)