c语言:求方程组的解(if的使用)

来源:互联网 发布:为什么会遭到网络诈骗 编辑:程序博客网 时间:2024/05/22 07:56
Code:
  1. /* 
  2. y=x     (x<1) 
  3. y=2*x-1 (1<=x<10) 
  4. y=3*x-11 (x>=10) 
  5.  
  6. */  
  7.   
  8. #include <stdio.h>  
  9.   
  10. #include <math.h>  
  11.   
  12. void main()  
  13. {  
  14.   
  15.     int a,b;  
  16.     printf("请输入1个数:");  
  17.     scanf("%d",&a);  
  18.     if (a<1){  
  19.         b = a;  
  20.     }else if(a<10 && a>=1){  
  21.   
  22.         b = 2*a-1;  
  23.     }else{  
  24.         b = 3*a-11;  
  25.     }  
  26.   
  27.     printf("方程的值是:%d/n",b);  
  28. }