Problem F: 2023CSP演练-阅读程序-3

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Special Judger Creator:
Submit:13 Solved:8

Description

2

#include <cstdio>

#include <iostream>

using namespace std;

 

int main()

{

       int n,k=0,s;

       scanf("%d",&n);

    for(int i=2; i*i<=n; i++)   //6

    {

           if(n%i==0)

           {

                  while(n%i==0)

                  {

                         k++;

                         if(k==1)  printf("%d",i);  //13

                         else  printf(" * %d",i); //14

                         n=n/i;

                     }

              }

       }

       if(n!=1)

       {

              k++;

              if(k==1)  printf("%d",n);  //23

           else  printf(" * %d",n);    //24

       }

       return 0;

}

 

判断题

1)  n0,则输出为值为0(     )

2)  n1,则输出为值为1(     )

3)  若将第13行的“k==1”改为“k>0”,程序输出的结果不会改变。(        )

4)  此程序是求nk个质因数。(          )

 

选择题

 5) 若输入n100,则第六行的循环变量i(     )时退出循环

A) 11      B) 10     C)  6     D)  7

 

 6) 若输入n127,则此程序会在第(     )行输出结果         

A) 13      B) 14      C) 23     D) 24