第三章

我的未来我决定 提交于 2020-11-15 23:51:56

#2.

#include<stdio.h>
int main(){
	int input;
	printf("输入ASCII码值:");
	scanf_s("%d", &input);
	printf("You input value is %d,and char is %c\n", input, input);
	return 0;
}

#3.

include<stdio.h>
int main(){
	char ch = ‘\a‘;
	printf("输入ASCII码值:");
	printf("%c", ch);
	printf("Starled by the sudden sound,Sally shouted,\n");
	printf("\"By the Great Pumkin,what was that!\"\n");
	return 0;
}

#4.

nt main(void) {
	float input;
	printf("Enter a floating-point value:");
	scanf_s("%f", &input);
	printf("打印普通形式:%f\n", input);
	printf("打印指数形式:%e\n",input);
	printf("打印p计数法形式:%a\n", input);
	return 0;
}
```

#5

```
#include <stdio.h>
#define SEC_PER_YEAR 3.156e7
int main(void) {
	float second,year;
	printf("输入多少岁:");
	scanf_s("%f", &year);
	second = year * SEC_PER_YEAR;
	printf("你是%lf岁。\n",year);
	printf("你活了%e秒。\n",second);
	return 0;

#6.

#include <stdio.h>
#define SEC_PER_YEAR 3.0e-23
#define a 950
int main(void) {
	float b,c;
	printf("输入多少水:");
	scanf_s("%f", &b);
	c = b * SEC_PER_YEAR / a;
	printf("有多少夸脱数:\n",c);
	return 0;
}

#7.

include <stdio.h>
#define INCH_TO_CM 2.54
int main(void) {
	float a,b;
	printf("输入英寸身高:");
	scanf_s("%f", &a);
	b = a * INCH_TO_CM;
	printf("你%0.2f 英米高,%0.2f cm 高\n",a,b);
	return 0;
}

#8.

#include <stdio.h>
#define PINT_CUP 2
#define CUP_OUNCE 8
#define OUNCE_SPOON 2
#define SPOON_TEA 3

int main(void) {
	float pint, cup, ounce, spoon, tea_spoon;
	printf("输入多少cup:");
	scanf_s("%f", &cup);
	pint = cup / PINT_CUP;
	ounce = cup * CUP_OUNCE;
	spoon = ounce * OUNCE_SPOON;
	tea_spoon = spoon * SPOON_TEA;
	printf("%.1f cup equals %.1f pint, %.1f spoon, %.1f tea_spoon.\n",cup,pint,ounce,spoon, tea_spoon);
	return 0;
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!