PAT(Advance Level)Practice1002

题目分析:

输入
2项 2.4*a^1+3.2*a^0
2项 1.5*a^2+0.5*a^1
输出
2.4*a^1+1.5*a^2+0.5*a^1+3.2
3项 =1.5*a^2+2.9*a+3.2

Java pat 1002在实践中遇到的问题:

1.Please be accurate to 1 decimal place.

翻译:请精确到小数点后一位

2.Notice that there must be NO extra space at the end of each line

翻译:每行的某位不能有额外的空格。

3.K is the number of nonzero terms in the polynomial,

翻译:K是多项式中非0项的数目。

4. Ni and a~Ni~ (i=1, 2, ..., K) are the exponents and coefficients,

翻译:Ni和a~Ni(i=1, 2,…,K)是指数和系数

5.java 怎么定义数组并初始化:

一.数组:
数组的定义:
一维数组的定义:
type [ ] arr_name;
type arr_name[ ];
二维数组的定义:
type [ ][ ] arr_name;
type arr_name [ ][ ];
多维数组的定义:
int [ ] arr1;
String [ ] arr2;
float arr3[ ];
String [ ][ ] arr4;

二.数组的初始化:
静态初始化:(定义的同时指定数组元素的内容)
int [ ] arr1={1,2,3,4,5};
String [ ] arr2={"tom","rose","sunny"};
String [ ][ ] arr3 ={{"tom","American"},{"jack","england"},{"张三","china"}};
动态初始化:(定义的同时通过new关键字开辟指定大小的存储空间)
int [ ] arr1=new int [2] ;
arr1[0] =10;
arr2[1]=20;
arr3[2]=30;

6.Java数组内元素由大到小排序:

1 for(int p=0;p<(K2+(K1-num));p++) {
2     for(int q=p+1;q<(K2+(K1-num));q++) {
3         if(a[p]<a[q]) {
4             temp=a[p];
5             a[p]=a[q];
6             a[q]=temp;
7         }    
8     }
9 }
排序

7Java中的Boolean类型怎么写:

猜你喜欢

转载自www.cnblogs.com/Catherinezhilin/p/9316512.html
今日推荐