當前位置:首頁 » 編程軟體 » 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;
}

熱點內容
php辦公系統 發布:2025-07-19 03:06:35 瀏覽:899
奧德賽買什麼配置出去改裝 發布:2025-07-19 02:53:18 瀏覽:40
請與網路管理員聯系請求訪問許可權 發布:2025-07-19 02:37:34 瀏覽:189
ipad上b站緩存視頻怎麼下載 發布:2025-07-19 02:32:17 瀏覽:844
phpcgi與phpfpm 發布:2025-07-19 02:05:19 瀏覽:527
捷達方向機安全登錄密碼是多少 發布:2025-07-19 00:57:37 瀏覽:692
夜魔迅雷下載ftp 發布:2025-07-19 00:39:29 瀏覽:99
增值稅票安全接入伺服器地址 發布:2025-07-19 00:20:45 瀏覽:486
solidworkspcb伺服器地址 發布:2025-07-18 22:50:35 瀏覽:822
怎麼在堆疊交換機里配置vlan 發布:2025-07-18 22:42:35 瀏覽:630