View Code of Problem 69

//有一个函数
//y={ x      x<1
//    | 2x-1   1<=x<10
//    \ 3x-11  x>=10
//
//写一段程序,输入x,输出y
#include<stdio.h>
int f(int x);
int main()
{
	int n,y;
	scanf("%d",&n);
	y=f(n);
	printf("%d",y);
	return 0;
}
int f(int x)
{
	int y;
	if(x<1)
	{
		y=x;
	}
	else if(x<10)
	{
		y=2*x-1;
	}
	else y=3*x-11;
	return y;
}

Double click to view unformatted code.


Back to problem 69