當前位置:首頁 » 編程軟體 » c語言編譯不等式組

c語言編譯不等式組

發布時間: 2023-12-21 15:26:43

1. c語言中這個不等式怎麼編 用switch語句

#include "stdio.h"
#include "conio.h"

main()
{
double x;
int temp,y;
printf("input a number:");
scanf("%lf",&x);
temp=(x>=0?(x>0?1:0):-1);
switch(temp){
case 1:
y=1;break;
case 0:
y=0;break;
case -1:
y=-1;break;

}
printf("y=%d\n",y);
getch();
}
若對這個表達式不懂的temp=(x>=0?(x>0?1:0):-1);可以繼續追問 。編譯環境是win-TC下的,你可以把getch()替換成getchar()防止屏幕一閃而過

2. C語言中不等式可不可以連寫

不可以的。應為
(x<=a)&&(x>=b&&x<=c)

3. 懸賞求一個簡單的C語言解不等式的程序

#include<stdio.h>
intmain(void)
{
intx1,x2,x3;
floatt;
floatsum;
scanf("%f",&t);
for(x1=0;x1<10;x1++){
for(x2=0;x2<10;x2++){
for(x3=0;x3<10;x3++){
sum=4.71*x1+3.615*x2+4.73*x3;
if(sum<=t)
printf("x1:%d,x2:%d,x3:%d ",x1,x2,x3);
}
}
}

return0;
}

熱點內容
星火雲伺服器 發布:2025-03-18 00:13:06 瀏覽:707
ci框架indexphp 發布:2025-03-18 00:11:16 瀏覽:678
編程設計基礎 發布:2025-03-18 00:09:36 瀏覽:299
寬頻撥號連接中賬戶密碼是什麼 發布:2025-03-17 23:49:06 瀏覽:359
android貪吃蛇 發布:2025-03-17 23:45:57 瀏覽:69
zbar源碼 發布:2025-03-17 23:42:18 瀏覽:771
水星wifi改密碼怎麼改 發布:2025-03-17 23:41:39 瀏覽:791
編程班表 發布:2025-03-17 23:41:34 瀏覽:882
網上鄰居訪問許可權 發布:2025-03-17 23:41:31 瀏覽:391
國行安卓11如何使用谷歌 發布:2025-03-17 23:40:52 瀏覽:147