作业3-1

//输入一个整数 x,计算并输出下列分段函数  sign(x)  的值
#include<stdio.h>
int main(void)
{
    int x,y;
    printf("输入x:");
    scanf("%d",&x);

    if(x<0){
        y=-1;
    }
    else if(x==0){
        y=0;
    }
    //运用if的语句
    else{
        y=1;
    }
    printf("y=%d",y);
    return 0;
}

posted @ 2013-10-19 23:33  plusfancy  阅读(130)  评论(0编辑  收藏  举报