简单java作业求助
用cmd运行作业可以得出如下图形:**********那个图形模仿得不好,应该更对称才对最好能帮我做一个99乘法表.....
用cmd运行作业可以得出如下图形:
*
**
***
****那个图形模仿得不好,应该更对称才对
最好能帮我做一个99乘法表.. 展开
*
**
***
****那个图形模仿得不好,应该更对称才对
最好能帮我做一个99乘法表.. 展开
3个回答
展开全部
源程序一:
public class baidu_1
{
public static void main(String args[])
{
String str[]={" "," "," "," "};
for(int i=1;i<=4;i++)
{
System.out.print(str[i-1]);
for(int j=1;j<=i;j++) //输出第i行的*
{
System.out.print(" *");
}
System.out.println(); //输出回车换行
}
}
}
源程序二:
public class baidu_2
{
public static void main(String args[])
{
for(int i=1;i<=9;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(i+"*"+j+"="+(i*j)+" ");
}
System.out.println();
}
}
}
展开全部
import java.io.IOException;
import java.io.OutputStream;
public class Triangle {
private int level;
public Triangle(int level) {
this.level = level;
}
public void draw(OutputStream out) throws IOException {
for (int i = 1; i <=level; i++) {
draw(out,level-i,' ');
draw(out,(i-1)*2+1,'*');
draw(out,1,'\n');
}
}
private void draw(OutputStream out, int cnt, char c) throws IOException {
for (int i = 0; i < cnt; i++) {
out.write((byte) c);
}
}
public static void main(String[] args) throws IOException {
Triangle triangle = new Triangle(7);
triangle.draw(System.out);
System.out.flush();
}
}
符号应为奇数方可对齐。
public class Table99 {
public static void main(String[] args) {
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(i+"*"+j+"="+i*j);
System.out.print(i*j<10?" ":" ");
}
System.out.println();
}
}
}
import java.io.OutputStream;
public class Triangle {
private int level;
public Triangle(int level) {
this.level = level;
}
public void draw(OutputStream out) throws IOException {
for (int i = 1; i <=level; i++) {
draw(out,level-i,' ');
draw(out,(i-1)*2+1,'*');
draw(out,1,'\n');
}
}
private void draw(OutputStream out, int cnt, char c) throws IOException {
for (int i = 0; i < cnt; i++) {
out.write((byte) c);
}
}
public static void main(String[] args) throws IOException {
Triangle triangle = new Triangle(7);
triangle.draw(System.out);
System.out.flush();
}
}
符号应为奇数方可对齐。
public class Table99 {
public static void main(String[] args) {
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(i+"*"+j+"="+i*j);
System.out.print(i*j<10?" ":" ");
}
System.out.println();
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
/**
说明:你的打印1,2,3,4个*号根本不肯做到对称,你明白吗??
用cmd运行作业可以得出如下图形:
*
***
*****
*******
那个图形模仿得不好,应该更对称才对
问题补充:最好能帮我做一个99乘法表
我的回答如下=======================
*/
public class Test {
private static void print(int n) {
for (int i = 0; i < n; i++) {
for (int k = n; k > i; k--) {
System.out.print(" ");
}
for (int j = 0; j <= i * 2; j++) {
System.out.print("*");
}
System.out.println();
}
}
public static void nineNineMulitTable() {
for (int i = 1, j = 1; j <= 9; i++) {
System.out.print(i + "*" + j + "=" + i * j + "\t");
if (i == j) {
i = 0;
j++;
System.out.println();
}
}
}
public static void main(String[] args) {
print(4);// 参数控制行数-----------------
System.out.println("=========================================");
nineNineMulitTable();
}
}
说明:你的打印1,2,3,4个*号根本不肯做到对称,你明白吗??
用cmd运行作业可以得出如下图形:
*
***
*****
*******
那个图形模仿得不好,应该更对称才对
问题补充:最好能帮我做一个99乘法表
我的回答如下=======================
*/
public class Test {
private static void print(int n) {
for (int i = 0; i < n; i++) {
for (int k = n; k > i; k--) {
System.out.print(" ");
}
for (int j = 0; j <= i * 2; j++) {
System.out.print("*");
}
System.out.println();
}
}
public static void nineNineMulitTable() {
for (int i = 1, j = 1; j <= 9; i++) {
System.out.print(i + "*" + j + "=" + i * j + "\t");
if (i == j) {
i = 0;
j++;
System.out.println();
}
}
}
public static void main(String[] args) {
print(4);// 参数控制行数-----------------
System.out.println("=========================================");
nineNineMulitTable();
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询