题目描述
时间限制: 1 Sec 内存限制: 30 MB
提交: 34254 解决: 22657
[提交] [状态] [讨论版] [命题人:admin]
题目描述
对用户输入的任一整数,输出以下多项式的值。
y=2x2+x+8
输入
输入整数x的值。
输出
输出一个整数,即多项式的值。
样例输入 Copy
1
样例输出 Copy
11
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int x=input.nextInt();
System.out.println(2*x*x+x+8);
}
}
总结反思
1.书写标准化,排版整齐,方便阅读
增加了C++:
#include<iostream>
using namespace std;
int main() {
int x,y;
cin >> x;
y = 2 * x * x + x + 8;
cout << y<< endl;
return 0;
}
C++中的iostream头文件与C语言中stdio.h中的格式,函数都不同,区别是cin/cout不需要像printf/scanf一样判断数据的类型,所以更简练,但是给程序的运行速度施加的很大的压力,对于有些题会超时