正在加载图片...
nt num. hundreds. tens, units printf( " Input an integer( form 100 to 999): scanf(%d", &num) hundreds= num/100 tens num %100/10: units num %610: if((hundreds=tens)+(tens=units)+(hundreds==uni printf(“%d\n”,num); return 0: 5.5用case语句编程计算y值: cos(x+3.0) ≤x<10 cos2(x+7.5)10≤x<20 cos4(x+4.0)20≤x<30 解:用case语句编程的关键是如何巧妙地设计“选择开关”。 根据本题所提供的条件,我们将选择开关设计为表达式(int)x/10。 下面给出本题的一种解决方案 #include <stdio. h>4 int num,hundreds,tens,units; printf("Input an integer ( form 100 to 999 ): "); scanf("%d",&num); hundreds = num/100; tens = num % 100/10; units = num % 10; if((hundreds==tens)+(tens==units)+(hundreds==uni ts)==1) printf(“%d\n ”,num); return 0; } 5.5 用 case 语句编程计算 y 值: cos(x+3.0) 0≤x<10 y = cos2(x+7.5) 10≤x<20 cos4(x+4.0) 20≤x<30 解:用 case 语句编程的关键是如何巧妙地设计“选择开关”。 根据本题所提供的条件,我们将选择开关设计为表达式(int)x/10。 下面给出本题的一种解决方案。 #include <stdio.h>
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有