D.5两段函数求值

xiaoxiao2021-02-28  109

/* *copyright(c)2017,学院 *All rights reserved. *文件名称: main.c *作 者: 杨隆胜 *完成日期: 2017年8月5日 *版 本 号: v1.0 * *问题描述:编程序,计算下面函数的值并输出(x取整型即可) *输入描述:输入x; *程序输出:输出y; */ #include <stdio.h> int main() { int x,y; printf("Please input the integer argument x:\n"); scanf("%d",&x); if(x>=1) { y=x-1; } else { y=-x+1; } printf("The value of the funtion that caculating is %d\n",y); return 0; }

运行结果

心得体会

在编程过程中如果出现中文字符,对同一错误,编译器将会报错两次。好像在课程中老师有讲过,但是记不得了 ,果然是好脑不如 烂笔头。

转载请注明原文地址: https://www.6miu.com/read-28779.html

最新回复(0)