A, PTA operations summary
Third operation: 7-5 discount
1. experiment code
#include<stdio.h> int main(){ int a,b; scanf("%d %d",&a,&b); double c=a*1.0*b*0.1; printf("%.2f",c); }
2 design ideas
The first step: define the variable a: b Price: Discount
Step 2: Ask the user input variables a and b
of the third step: Define floating point variable c: After the discount price and the calculated value of c
Step four: output value of c
flow chart:
3. This question debugging process encountered problems and solutions
no
Fifth operation: sign function value calculating 7-2
1.实验代码
#include <stdio.h> int main(){ int n,sign; scanf("%d",&n); if (n<0){ sign=-1; } else if(n>0){ sign=1; } else{ sign=0; } printf("sign(%d) = %d",n,sign); return 0; }
2 设计思路
第一步:定义变量 n , sign
第二步:让用户输入变量 n
第三步:判断 n是否小于0 若结果为是 则sign赋值为-1 结束判断
若结果为否 判断 n是否大于0 若结果为是 则sign赋值为1 结束判断
若结果为否 则sign赋值为0 结束判断
第四步:输出函数sign的表达式和n,sign的值
流程图:
3.本题调试过程碰到问题及解决办法
无