msww.net
当前位置:首页 >> C语言输入x输出y >>

C语言输入x输出y

123456789101112 #include<stdio.h> voidmain() { intx,y; scanf("%d",&x); if(x<0&&x>=-2) printf("y=%d\n",x); if(x==0) printf("y=%d\n",x-1); if(x>0&&x<=2) printf("y=%d\n",x+1); }

1234567891011121314151617 #include <stdio.h> intmain() { intx , y; scanf("%d",&x); if(x < 1) { y = x - 1; printf("%d %d\n", x, y); }elseif(x > 1 || x == 1){ y = 2 * x + 1; printf("%d %d\n", x, y); } }

我把核心的给你写一下,编程还是要自己动手,要不你永远也学不会的.scanf("%f",&x);if(x>=-2&&x<0)y=x;elseif(x==0)y=x-1;elseif(x>0&&x<=2)y=x+1;elseprintf("输入有误\n");

#include void main() { int x,y; if(x>=1&&x=10) y=3*x-11; printf("qing su ru x"); scanf("%d",&x); printf("%d",y); }

应该是这样.else{if(1

scanf("%d",&x); //y不用输入 if (x<=1) { y=x; printf("%d\n",y);} //条件copyx<=1成立时,这两句都要执行,所以要用{}变成复合语句.知 else if(x>1&&道x<10) { y=2*x+1; printf("%d\n",y);} //同上 else {y=3*x+1; printf("%d\n",y);} //同上 更好的是: scanf("%d",&x); if (x<=1) y=x; else if(x>1&&x<10) y=2*x+1; else y=3*x+1; ); // y求值 printf("%d\n",y); //输出y

#include <stdio.h> int main() { int x; scanf("%d",x); printf("%d", x>=10? 2x-11:2x-1); } #include <stdio.h> int main() { int x; scanf("%d",x); printf("%d",x<1?x:( x>=10? 2x-11:2x-1)); }

#include using namespace std; int main() { int x; int y; cin>>x; if(-5 y=x; else if(x=0) y=x-1; else if(0 y=x+1; cout return 0; }

111111111111111111111111111111111111111113h5jj

#include<stdio.h>#include<math.h>main(){ float x,y; while(1){ printf("请输入x="); scanf("%f",&x); if(x>=-5&&x<10&&x!=-1) break; /*x=-5到底该怎么做?你的题目和你的程序处理方法不一样,我这是根据你的程序修改的*/ } if(x<0&&-5<=x)y=1/(1

网站首页 | 网站地图
All rights reserved Powered by www.msww.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com