xsxshxs2 于 2015.05.31 06:28 提问

【问题描述】

【输入格式】

【输出格式】
1行，包含r-l+1个数，第i个数表示x值为l+i-1时多项式的值
【输入样例】
2 3 5 7 11
【输出样例】
124 157 194 235 280

3个回答

gamefinity   2015.05.31 07:03

``````#include <stdio.h>

void main()
{
double a, b, c;
int l, r;

printf("pls input a,b,c,l,r:");
scanf("%lf %lf %lf %d %d", &a, &b, &c, &l, &r);

for (; l <= r; l++)
{
printf("l=%d;a*x^2+b*x+c=%lf\n", l, a * l * l + b * l + c);
}
}
``````
u010209442   2015.05.31 09:07

#include

void main()
{
double a, b, c;
int l, r;

``````printf("pls input a,b,c,l,r:");
scanf("%lf %lf %lf %d %d", &a, &b, &c, &l, &r);

for (; l <= r; l++)
{
printf("l=%d;a*x^2+b*x+c=%lf\n", l, a * l * l + b * l + c);
}
``````

}

tongyi55555   2015.05.31 11:41

JAVA代码

``````     private void printAbclr() {
// TODO Auto-generated method stub
System.out.println("请输入5个参数，分别表示a、b、c、l和r，中间用空格分隔：");
Scanner scanner = new Scanner(System.in);
String inStr = scanner.nextLine();
String[] valueStr = inStr.split(" ");
double a = Double.valueOf(valueStr[0]);
double b = Double.valueOf(valueStr[1]);
double c = Double.valueOf(valueStr[2]);
int l = Integer.valueOf(valueStr[3]);
int r = Integer.valueOf(valueStr[4]);
double value = 0;
for (int i = l; i <= r; i++) {
value = a * i * i + b * i + c;
System.out.print(value+" ");
}
}
``````

``````请输入5个参数，分别表示a、b、c、l和r，中间用空格分隔：
2 3 5 7 11
124.0 157.0 194.0 235.0 280.0
``````