公众号【C you again】回复 “浙大版C语言” 查看每道题目详细实现思路
公众号【C you again】回复 “编程交流群” 进C/C++/Java编程题交流、问题解答群
对于任一整数n,符号函数sign(n)的定义如下:
请编写程序计算该函数对任一输入整数的值。
输入格式:
输入在一行中给出整数n。
输出格式:
在一行中按照格式“sign(n) = 函数值”输出该整数n对应的函数值。
输入样例1:
10
输出样例1:
sign(10) = 1
输入样例2:
0
输出样例2:
sign(0) = 0
输入样例3:
-98
输出样例3:
sign(-98) = -1
代码:
#include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
if(n>=0)
{
if(n>0) printf("sign(%d) = 1
",n);
else printf("sign(%d) = 0
",n);
}
else printf("sign(%d) = -1
",n);
}
作者: C you again,从事软件开发 努力在IT搬砖路上的技术小白
公众号:【
C you again】分享计算机类毕业设计源码、IT技术文章、游戏源码、网页模板、程序人生等等。公众号回复 【
粉丝】进博主技术群,与大佬交流,领取干货学习资料
关于转载:欢迎大家转载本文,转载时表明出处
求赞环节:创作不易,记得
点赞+
评论+
转发
,谢谢你一路支持