feibols

导航

 

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

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

学号:0102600135

姓名:林梓涵

一、代码演示:
(1) #include<stdio.h>

int main(void)

{

int i = 2147483647;

unsigned int j = 4294967295;

printf("%d %d %d\n", i, i+1, i+2);

printf("%u %u %u\n", j, j+1, j+2);

return 0; }

QQ20261020-204456
(2) #include<stdio.h>

int main(void)

{

float aboat = 32000.0;

double abet = 2.14e9;

long double dip = 5.32e-5;

printf("%f can be written %e\n", aboat, aboat);

printf("%f can be written %e\n", abet, abet);

printf("%f can be written %e\n", dip, dip); }

QQ20261020-204537
(3) #include<stdio.h>

int main(void)

{

float f;

f = 123.456;

if (f == 123.456)

printf("f is equal to 123.456 indeed.");

else printf("In fact, f is equal to %f\n", f); }

QQ20261020-204611
(4) #include<stdio.h>

int main(void)

{

int a,b,c=323;

float x,y=8.88;

char c1='a',c2;

a=y;

x=c;

b=c1;

c2=c;

printf("%d,%f,%d,%c \n",a,x,b,c2); }
QQ20261020-204648
(5)#include<stdio.h>

int main(void)

{

char ch;

int i;

float f;

double d;

printf("%u %u %u %u\n", sizeof(ch),sizeof(i),sizeof(f),sizeof(d));

printf("%u %u %u\n", sizeof(ch/i),sizeof(f*d),sizeof(f+i));

printf("%u\n",sizeof(ch/i + f*d -(f+i))); return 0; }

QQ20261020-204732
二,书本程序演示:
3.1

3
3.2

3
3.3

3
3.4

3
3.5

3
3.8

3
3.9

3
三、书本3.11作业:
1.

311

311
2.

311

311
3.

3113代码

3113结果
4.

311

311
5.

311

311
6.

311

311
7.

311

311
8.

311

311
使用浮点数能在缩小换算时更准确,误差更小。
四、设计一个程序完成以下内容的不同形式输出。
(1)按小数形式输出实数:%f 由系统指定宽度(6位小数), %m.nf 指定宽度m,小数位数n,右靠齐, %-m.nf 指定宽度m,小数位数n,左靠齐 (注意:宽度包括符号和小数点)。
(2)用于输出字符串:%s 不指定宽度, %-ms 指定宽度,左靠齐, %ms 指定宽度,右靠齐, %m.ns 指定宽度m,只取左端n个字符, 右靠齐, %-m.ns 指定宽度m,只取左端n个字符, 左靠齐。

课外1与课外2 代码

课外1与课外2 结果

总结思考:
本次作业中,通过实践完善了自己于课堂知识的不足,借助AI工具检查错误,发现了scanf()函数中对double量应用%lf来做标识符等问题。

posted on 2026-10-22 16:49  feibols  阅读(7)  评论(0)    收藏  举报