[简答题]
以下是某C程序段及其功能描述,请仔细阅读程序并完成要求
企业发放的奖金根据利润提成,发放规则如下:
利润(Ⅰ)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.5%;20万到40万之间时,高于20万元的部分,可提成5%;40万到60万之间时高于40万元的部分,可提成3%;60万到100万之间时,高于60万元的部分,可提成1.5%,高于100万元时,超过100万元的部分按1%提成。从键盘输入当月利润Ⅰ,输入应发放奖金总数。
#include
#include
int
main( )
{
long int gain;
int
prizel, prize2, prize4, prize6, prize10,prize=0;
puts("************************************");
puts("*
The program will solve *");
puts(" *
the problem of prize distribution * "):
puts("
************************************");
puts("please input the
mum of gain:");
scanf("%ld", &gain);
prizel=100000*0.1:
prize2=prizel+i00000*0.075:
prize4=prize2+200000*0.05:
prize6=prize4+200000*0.03:
prize10=prize6+400000*0.015:
if(gain<=100000)
prize=gain*0.1:
else if(gain<=200000)
prize=prizel+(gain-i00000)*0.075;
else
if(gain<=400000)
prize
[简答题]
以下是某C程序段,其功能为计算输入数字的阶乘。请仔细阅读程序并完成要求。
#incllJde
#include
int
main( )
{
int i=0;/*i为计数器*/
int
n;
i nt factorial=1; /*保存阶乘的结果*/
puts("
************************************* ");
puts(" * The
program will compute *");
puts(" * the factotial of an
integer * ");
puts(" *************************************
");
puts(" please input the number n: ");
scanf(" % d", &n);
if(n<0)/*判断输入的数是否大于或等于0*/
(
printf(" please input an interger>=0./n");
return 0;
}
if(n= =0)/* 0的阶乘是1*/
{
printf(" factorial of 0 is 1./n");
return 0;
)
i=1;
while(i<=n)
{
factorial=factorial *
i;
i++;
}
printf(" factorial of
% d is:%d./n", n, factorial);
geteh( );
return
0;
[简答题]
以下是某C程序段,其功能为计算输入数字的阶乘。请仔细阅读程序并完成要求。
#include<stdio.
h>
#include<stdlib. h>
int main( )
{
int i=0;/*i为计数器*/
int n;
int factorial=1;/*保存阶乘的结果*/
puts("*************************************"):
puts("*The
program will compute *");
puts("*the factotial of
an integer *");
puts("*************************************"):
puts("please input the number n:");
scanf("%d",&n);
if(n<0)/*判断输入的数是否大于或等于0*/
{
printf("please input an interger>=0. /n");
return 0;
}
if(n==0)/*0的阶乘是1*/
{
printf("factorial of 0 is 1./n");
return
0;
}
i=1;
while(i<=n)
{
factorial = factorial *
i;
i++:
}
printf("factorial of % d is:%d. /n",n,factorial);
getch( );
return 0:
}
[简答题]以下是某C程序段,其功能为计算输入数字的阶乘。请仔细阅读程序并完成要求。
#include
#include
int main( )
int i = 0;/* i为计数器 */
int n;
int factorial = 1;/* 保存阶乘的结果 */
puts("*************************************");
puts("* The program will compute *");
puts("* the factotial of an integer *");
puts("*************************************");
puts("please input the number n:");
scanf("%d",&n);
if(n < 0)/*判断输入的数是否大于或等于0*/
printf("please input an interger >= 0./n");
return 0;
if(n==0)/* 0的阶乘是1 */
printf("factorial of 0 is 1./n");
return 0;
i = 1;
while(i <= n)
factorial = factorial * i;
i++;
printf("factorial of %d is:%d./n",n,factorial);
getch( );
return 0;
画出此程序主函数的控制流程图。
[简答题]以下是某C程序段,其功能为计算输入数字的阶乘。请仔细阅读程序并完成要求。
# incllade<stdiO.h>
# incllade<stdl ib.h>
int main( )
int i:0;/*i为计数器*/
int n:
int factorial=1;/*保存阶乘的结果*/
puts("*************************************"):
puts("* The program will compute*");
puts("* the fact。tial 0f an integer*");
puts("*************************************"):
puts("please input the number n:");
scanf("%d’,&n);
if(n<0)/*判断输入的数是否大于或等于0*/
printf("please input an interget>=0./n");
return 0:
if(n==0)/*0的阶乘是1*/
printf("fa(:tOrial of 0 is 1./n");
return 0:
i=1:
while(i<=n)
factorial:factorial * i:
i++:
printf("factorial of %d is:%d./n’,n,factorial);
getch( );
return 0:
出此程序主函数的控制流程图。
[简答题]以下是某C程序段,其功能为计算输入数字的阶乘。请仔细阅读程序并完成要求。
#include<stdio.h>
#include<stdlib.h>
int main( )
int i=0;/*i为计数器*/
int n;
int factorial=1;/*保存阶乘的结果*/
puts("*****************************************");
puts("*The program will compute*");
puts("*the factotial of an integer*");
puts("*****************************************");
puts("please input the number n:");
scanf("%d", &n);
if(n<0)/*判断输入的数是否大于或等于0*/
printf("please input an interger>=0./n");
return 0;
if(n==0)/*0的阶乘是1*/
printf("factorial of 0 is 1./n");
return 0;
i=1;
while(i<=n)
factorial= factorial * i;
i++;
printf("factorial of %d is: %d./n", n, factorial);
getch( );
return 0;
画出此程序主函数的控制流程图。
[简答题]以下是某C程序段,其功能是计算输入数据是否为水仙花数,请仔细阅读程序并完成要求。
#include
void main( )
int i,a,b,c;
scanf("%d ",&i);
a=i/100;
b=i/10%10;
c=i%10;
if(i==a*a*a+b*b*b+c*c*c)
printf("%d/n",i);
画出此程序主函数的控制流程图。
[简答题]
以下是某C语言程序段,其功能是计算输入数据是否为水仙花数,请仔细阅读程序并完成要求。
#include
void main( )
{
int i,a,b,c;
scanf("%d",&i);
a=i/100;
b=i/10%10:
C=i%10:
if(i==a*a*a+b*b*b+c*c*c)
printf("%d/n",i);
}
设计一组测试用例,使该程序所有函数的语句覆盖率和分支覆盖率均能达到100%。如果认为该程序的语句或分支覆盖率无法达到100%,需说明为什么。 |