题解 1007: [编程入门]分段函数求值

来看看其他人写的题解吧!要先自己动手做才会有提高哦! 
返回题目 | 我来写题解

筛选

[编程入门]分段函数求值-题解

摘要:解题思路:x<1时,y=x;x>=10时,y=3*x-11;其他x的情况(即1=<x<10时),y=2*x-1;注意事项:1、函数分三段,任给x只需要进行两次判断【if()里面一次,else if()……

用switch解题熟悉switch

摘要:解题思路:注意事项:参考代码:#include<stdio.h>int main(){ int x; int n,y; scanf("%d",&x); if(x<1) n = 1; if(x>=1 &……

简单代码易理解

摘要:解题思路:注意事项:参考代码:#include <stdio.h>int main(){ int x,y; scanf("%d",&x); if(x>=1) if(x<10) y=2*x-1; ……

分段函数—题解

摘要:解题思路:注意事项:如果使用elif,其实之前的条件就不用写了参考代码:x=int(input())if x<1:    y=xelif x<10:    y=2*x-1else:    y=3*x-……

分段函数处理

摘要:解题思路:分支结构应用注意事项:判断条件的设置参考代码:……

使用函数的定义和调用

摘要:解题思路:注意事项:参考代码:#include <iostream>using namespace std;int x=0,y;void cst();/* run this program using……

分段函数求值

摘要:解题思路:注意事项:参考代码:#include<stdio.h>int main(){ int a; scanf("%d",&a); if(a<1){ printf("%d\n",a); }else……