Java题.docVIP

  • 33
  • 0
  • 约1.17万字
  • 约 18页
  • 2017-02-08 发布于重庆
  • 举报
Java题

Description 输出以下菱形图案: Input Output 菱形图案。 Sample Input 5 9 #includeiostream using namespace std; class LX { public: LX(int a):n(a){} void getLX(); private: int n; }; void LX::getLX() { int i; int m; int k=(n-1)/2; for(i=1;;i++) { m=k; for(;m0;m--) cout ; k--; for(int s=1;s2*i;s++) cout*; coutendl; if((2*i-1)==n) break; } i-=1; k+=2; for(;i0;i--) { m=k; for(;m0;m--) cout ; k++; for(int s=1;s2*i;s++) cout*; coutendl; } } int main() { int n; while(cinn) { LX myL(n); myL.getLX(); } return 0; } Other: #includeiostream using namespace std; class lx{ public: lx(int a){n=a;} void show(){ int i,j,k; for(i=1;i=n/2+1;i++){ for(j=0;j(n/2)+1-i;j++) cout ; for(k=0;k2*i-1;k++){ cout*; } coutendl; } for(i=1;i=n/2;i++){ for(j=0;ji;j++) cout ; for(k=0;kn-(2*i);k++){ cout*; } coutendl; } } private: int n; }; int main() { int l; while(cinl) { lx a(l); a.show(); } } 陶陶家的院子里有一棵苹果树,每到秋天树上就会结出10个苹果。苹果成熟的时候,陶陶就会跑去摘苹果。陶陶有个板凳,当她不能直接用手摘到苹果的时候,就会踩到板凳上再试试。 ??现在已知10个苹果到地面的高度,以及陶陶把手伸直的时候能够达到的最大高度,请帮陶陶算一下她能够摘到的苹果的数目。假设她碰到苹果,苹果就会掉下来。 Input ??有多组数,每组数由12个整型数组成。第1个整型数表示陶陶将手伸直时能达到的最大高度,第2个整型数表示凳子的高度,后10个整型数表示10个苹果距离地面的高度。 Output ??陶陶能够摘到的苹果数目。 Sample Input 110 30 100 200 150 140 129 134 167 198 200 111 144 33 122 145 187 177 168 154 132 118 148 124 Sample Output 5 9 #includeiostream using namespace std; class PG { public: PG(int a,int b):h(a),sH(b){} int HowMany(int a[10]); private: int h,sH; }; int PG::HowMany(int a[10]) { int n=0; int t=h+sH; for(int i=0;i10;i++) if(a[i]=t) n++;

文档评论(0)

1亿VIP精品文档

相关文档