#include<stdio.h>intmain(void){int x, y =0;scanf("%d",&x);if( x <1){printf("y = %d\n", x);}elseif( x <30){printf("y = 3x + 5 = %d\n",3* x +5);}else{printf("y = 7x - 3 = %d\n",7* x -3);}return0;}
#include<stdio.h>#include<math.h>intmain(void){int x;scanf("%d",&x);if( x <0){printf("%d\n",abs(x));//abs(x) 求x的绝对值符号}else{printf("%d\n", x);}return0;}
#include<stdio.h>#include<math.h>/*
海伦-秦九韶公式
设三角形ABC三个角A、B、C的对边分别为a、b、c,
三角形ABC的面积为S,则S=“p(p-a)(p-b)(p-c)的算术平方根”。
其中p等于三角形周长的一半。即p=(1/2)x(a+b+c)。
*/intmain(void){double a, b, c;double p, area_sqrt, area;printf("请输入三角形的三边:");scanf("%lf%lf%lf",&a,&b,&c);if(( a+b > c )&&( a+c > b )&&( b+c > a )){
p =(a+b+c)/2;
area_sqrt = p *(p-a)*(p-b)*(p-c);
area =sqrt(area_sqrt);printf("三角形面积为:%.02f\n", area);}else{printf("error\n");}return0;}