#include <stdio.h>void main(){int x,y;printf("请输入x的值:");scanf("%d",&x);if(x==0) y=-1;else if(x<0&&x>-5)y=x;else if(x>0&&x<10)y=x+1;elseprintf("你输入的x不在-5到10之内!");printf("y的值为%d",y);}
#include<stdio.h>main(){ int x,y; scanf("%d",&x); if(x>-5&&x<0) y=x; else if(x==0) y=x-1; else if(x>0&&x<10) y=x+1; else printf("the error!"); printf("%d\n",y);}你应该是个初学者吧!其实这题不难。只要你好好学,这种题对你以后来说就一点没难度了!学C语言关键就是一个数学思维的处理,能够把数学的思想转换为C语言就行了!
#include <iostream>using namespace std;int main(){int x,y;cout<<"请输入X的值(X为-5到10之间的整数):"<<endl<<"X=";cin>>x;if(x>-5&&x<0)cout<<"Y的值为:"<<x<<endl;if(x==0){y=x-1;cout<<"Y的值为:"<<y<<endl;}if(x>0&&x<10)y=x+1;cout<<"Y的值为:"<<y<<endl;return 0;}不早说用C !!!!!
include<stdio.h>main(){ float x,y; printf("请输入x\n"); scanf("%f",&x); if(x==0) y=-1; else if(x>-5&&x<0) y=x; else if(x>0&&x<10) y=x+1; printf("y的值是%f\n",y); }
void main(){int x,y;scanf("%d",&x);if(x>0&&x<10) y=x+1;else if(x=0) y=x-1;else if(x>-5) y=xelse printf("输入错误");printf("%d",y);}