栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

c语言第四章实训第二次作业

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

c语言第四章实训第二次作业

选择题5

#include
int main()
#define N 8
{
	int x = 2, z = 1;
	double y = 1.2;
	switch (x)
	{
	case 2:
		y++;
		break;
	case '0':
		y = 3;
	}
	printf("%.2fn", y);
}

 

选择题9

#include
int main()
{
	int x, y;
	printf("整数:");
	scanf_s("%d", &x);
	switch (x-abs(x))
	{
	case 0:y = 1;
		break;
	default :y = -1;
	}
	printf("%d", y);
	return 0;
}

 阅读2

#include
int main()
{
	int i = 1, n = 0;
	switch (i)
	{
	case 1:
	case2:n++;
	case3: n++;
	}
	printf("%d", n);
	return 0;
}

编程3

#include
int main()
{
 int a, b;
 char c;
 scanf_s("%d %c %d", &a, &c,1, &b);
 switch (c) {
 case '+':
  printf("%d + %d = %d", a, b, (a + b));
  break;
 case '-':
  printf("%d - %d = %d", a, b, (a - b));
  break;
 case '*':
  printf("%d * %d = %d", a, b, (a * b));
  break;
 case '/':
  if (b == 0) {
   printf("b不可为0");
  }
  else {
   printf("%d / %d = %d", a, b, (a/b));
  }
  break;
 default:
  printf("运算符不在四则中");
  break;
 }
 return 0;
}

 编程4

#include
#include
int main()
{
	float salary, sale;
	printf("输入销售额:");
	scanf_s("%f", &sale);
	if (sale < 10000)
		salary = 1000;
	else if (sale < 20000)
		salary = 1000 + (sale - 10000) * 0.05;
	else if (sale < 50000)
		salary = 1000 + 10000 * 0.05 + (sale - 20000) * 0.06;
	else if (sale < 100000)
		salary = 1000 + 10000 * 0.05 + 30000 * 0.06 + (sale - 50000) * 0.07;
	else
		salary = 1000 + 10000 * 0.05 + 30000 * 0.06 + 50000 * 0.07 + (sale - 100000) * 0.08;
	printf("工资=%.3f", salary);
	return 0;
}

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/529067.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号