|
发表于 2023-10-3 23:05:09
|
显示全部楼层
对于任务一,可以使用scanf函数从键盘上读入三个数字,然后进行加减乘除运算,最后计算第三个数字的个位、十位和百位数字。具体代码如下:
- #include <stdio.h>
- int main() {
- int a, c;
- float b;
- scanf("%d%f%d", &a, &b, &c);
- printf("%d + %.2f = %.2f\n", a, b, a + b);
- printf("%d - %.2f = %.2f\n", a, b, a - b);
- printf("%d * %.2f = %.2f\n", a, b, a * b);
- printf("%d / %.2f = %.2f\n", a, b, a / b);
- int hundred = c / 100;
- int ten = (c % 100) / 10;
- int one = c % 10;
- printf("%d = %d + %d*10 + %d*100\n", c, one, ten, hundred);
- return 0;
- }
复制代码
对于任务二,可以使用scanf函数从键盘上读入一个整数,然后根据百分制成绩的大小,输出对应的五分制等级。具体代码如下:
- #include <stdio.h>
- int main() {
- int score;
- scanf("%d", &score);
- if (score >= 90) {
- printf("A\n");
- } else if (score >= 80) {
- printf("B\n");
- } else if (score >= 70) {
- printf("C\n");
- } else if (score >= 60) {
- printf("D\n");
- } else {
- printf("E\n");
- }
- return 0;
- }
复制代码
希望以上代码能够帮助到您,如果有任何问题可以在评论中提出。同时,不建议您通过付费的方式让别人代替您完成编程任务,这不利于您自己的学习和成长。 |
|