高级语言程序设计课程第三次个人作业

这个作业属于哪个课程:https://edu.cnblogs.com/campus/fzu/2026gjyycxsj

这个作业要求在哪里: https://edu.cnblogs.com/campus/fzu/2026gjyycxsj/homework/16749

学号:0102600113

姓名:林言辉

1. 作业内容

编写并运行书本第 4 章 4.8 编程练习题目中的第2题 ~ 第4题 , 第6题 ~ 第8题。

4.8.2

image

4.8.3

image

4.8.4

image

4.8.6

image

4.8.7

image

4.8.8

image

运行以下程序给出程序结果(无需代码,截图程序输出结果,如有错误可自行修改)。

(1) #include<stdio.h>
#include <string.h> // provides strlen() prototype
#define PRAISE "What a super marvelous name!"
int main(void)
{
char name[40];
printf("What's your name?\n");
scanf("%s", name);
printf("Hello, %s. %s\n", name, PRAISE); printf("Your name of %d letters occupies %d memory cells.\n", strlen(name), sizeof name);
printf("The phrase of praise has %d letters ", strlen(PRAISE));
printf("and occupies %d memory cells.\n", sizeof PRAISE); }
image

2) #include<stdio.h>
(#define SQUARES 64 //棋盘上的方格数
(#define CROP 1E15 //以粒计的美国小麦产量
int main(void)
{
double current, total;
int count = 1;
printf("square grains total ");
printf("fraction of \n");
printf(" added grains ");
printf("US total\n");
total = current = 1.0; // start with one grain
printf("%4d %13.2e %12.2e %12.2e\n", count, current, total, total/CROP);
while (count < SQUARES)
{
count = count + 1;
current = 2.0 * current;
total = total + current; // update total
printf("%4d %13.2e %12.2e %12.2e\n", count, current, total, total/CROP);
}
printf("That's all.\n"); }

image

(3) #include<stdio.h>
int main(void)
{
char ch; int i;
float fl;
fl = i = ch = 'C';
printf("ch = %c, i = %d, fl = %2.2f\n", ch, i, fl);
ch = ch + 1;
i = fl + 2 * ch;
fl = 2.0 * ch + i;
printf("ch = %c, i = %d, fl = %2.2f\n", ch, i, fl);
ch = 5212205.17;
printf("Now ch = %c\n", ch); return 0; }

image

(4) #include <stdio.h>
void pound(int n);
void main()
{
int times = 5;
char ch = '!';
float f = 6.0;
pound(times);
pound(ch);
pound((int) f);
}
void pound(int n)
{
while (n-- > 0)
printf("#");
printf("\n"); }

image

设计一个可以将程序运算符优先级展示出来的程序(例如自增或者自减运算与四则运算符混用)。
QQ20261029-170045

设计一个程序将这些运算符的优先级按照从高到低一行行展示出来

QQ20261029-170452

编写并运行书本第 5 章 5.11 编程练习题目中的第 1 题 ~ 第 9 题。

5.11.1
QQ20261029-172447

5.11.2
QQ20261029-180916

5.11.3
QQ20261029-181657

5.11.4
QQ20261029-183329

5.11.5
QQ20261029-222454

5.11.6
QQ20261029-222512

5.11.7
QQ20261029-224613

5.11.8
QQ20261029-233410

5.11.9
QQ20261029-235444

遇到的问题:对自定义函数运用不熟练,对while循环的使用不够熟练。
解决方法:通过不断向AI提问来弥补知识点,加上不断的操作逐渐熟悉。
总结与反思:作业中遇到了些许困难,通过借助AI工具,成功完成。

posted @ 2026-10-30 00:08  失败  阅读(7)  评论(0)    收藏  举报