给你一个C++版的好了~然后根据C++的改成JAVA的……
事实证明,上校偶果然算法很硕……如此简单的一个东西,代码写的毫无美感可言- -!:s006:
下面是代码:
引用:
#include <conio.h>
#include <iostream>
#include "SolveHead.h"
using namespace std;
int main()
{
int z = 0;
cout<<" "; // 为了第一行的那个空
for (int y = 0; y < 10; y++) // 纵轴
{
for (int x = 1; x < 10; x++) // 横轴
{
if (0 == y) // 横轴上的数字
{
cout<<x<<" ";
continue;
}
z = x * y; // 计算结果
if (y == z) // 纵轴上的数字
{
cout<<y<<" ";
}
cout<<z<<" ";
}
cout<<endl;
}
cout<<endl<<"Press any key to exit!"<<endl;
getch();
return 0;
}