第四章实训

#include<stdio.h>
int main()
{
 int m = 23, n = 5, x;
 x = !m + m % n;
 printf("%d", x);
 return 0;
}

#include<stdio.h>
int main()
{
 int x = 1, y = 2,z=1;
 if
  ((x > y) && (--x > 0))
  z = x;
 else
  x = z;
 printf("%d", x);
 return 0;
}

#include<stdio.h>
int main()
{
 int a = 0, b = 3, c = 2;
 if (a++ && b++)c--;
 else if (a + 1 == 6 || b--)c++;
 printf("%d,%d,%d", a, b, c);
 return 0;
}

#include<stdio.h>
int main() 
{
	int a = 0, b = 0, c = 0;
	if (a++ && (b += a) || ++c) {
		printf("%d,%d,%d\n", a, b, c);
	}
	return 0;
}

 

 

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

 

 

#include<stdio.h>
int main()
{
	int a = 3, b = 3, c = 2;
	if (!a && !b && c) {
		printf("a");
	}
	printf("b");
	return 0;
}

 

 

#include<stdio.h>
int main()
{
	int n = 8;
	n %= n - 2;
	printf("%d", n);
	return 0;
}

 

#include<stdio.h>
int main()
{
	int x, b = 2, a = 3;
	x = a > b++ ? (a++) : (b++);
	printf("%d,%d,%d", x, a, b);
	return 0;
}

 

#include<stdio.h>
int main()
{
	int x = 4, y = 3, z = 5;
	if (x > y) {
		z = x;
		x = y;
		y = z;
	}
	printf("%d,%d,%d", x, y, z);
	return 0;
}

 

 

#include<stdio.h>
int main()
{
	int a = 0, b = 2, c;
	b = --a || ++b;
	printf("%d", b);
	return 0;
}

 

 

#include<stdio.h>
int main()
{
	int x = 0, y = 1, z = 10;
	if (x) {
		if (y) {
			z = 20;
		}
		else {
			z = 30;
		}
	}
	printf("%d\n", z);
	return 0;
}

 

 

#include<stdio.h>
int main()
{
	int i = 1, n = 0;
	switch (i) {
	case 1:
	case 2:n++;
	case 3:n++;
	}
	printf("%d", n);
	return 0;
}

 

#include<stdio.h>
int main() 
{
	int x = 0, y = 0, z = 0;
	if (x++ && (y += x) || ++z) {
		printf("%d,%d,%d\n", x, y, z);
	}
	return 0;
}

#include<stdio.h>
int main() 
{
	int a;
	scanf_s("%d", &a);
	if (a % 2 == 0) {
		printf("偶数");
	}
	else {
		printf("奇数");
	}
	return 0;
}

 

#include<stdio.h>
#include <math.h>
int main()
{
	double a, b, c, x1, x2, r, i, delt;
	printf("请输入:");
	scanf_s("%lf%lf%lf", &a, &b, &c);
	if (fabs(a) <= 1e-6) {
		printf("1234");
	}
	else {
		delt = b * b - 4 * a * c;
		if (fabs(delt) <= 1e-6) {
			printf("%8.4f\n", -b / (2 * a));
		}
		else {
			if (delt > 1e-6) {
				x1 = (-b + sqrt(delt)) / (2 * a);
				x2 = (-b - sqrt(delt)) / (2 * a);
				printf("%8.4f和%8.4f", x1, x2);
			}
			else {
				r = -b / (2 * a);
				i = sqrt(-delt) / (2 * a);
				printf("%8.4f+%8.4f\n", r, i);
				printf("%8.4f-%8.4f\n", r, i);
			}
		}
	}
	return 0;
}

 

#include<stdio.h>
int main() 
{
	double a, b;
	char c;
	scanf_s("%lf%c%lf", &a, &c, 1, &b);
	switch (c) {
	case'+':
		printf("%lf%c%lf=%lf", a, c, b, a + b);
		break;
	case'-':
		printf("%lf%c%lf=%lf", a, c, b, a - b);
		break;
	case'*':
		printf("%lf%c%lf=%lf", a, c, b, a * b);
		break;
	case'/':
		if (b == 0) {
			printf("除数不能为零!");
		}
		else {
			printf("%lf%c%lf=%lf", a, c, b, a / b);
		}
		break;
	default:
		printf("输入错误");
	}
	return 0;
}

 

 

#include<stdio.h>
int main(void)
{
	float salary, sale;
	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 + (sale - 20000) * 0.06;
	else if (sale < 100000)
		salary = 1000 + (sale - 50000) * 0.07;
	else if (sale > 100000)
		salary = 1000 + (sale - 100000) * 0.08;
	printf("%.3f", salary);
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值