如题所述
C++的我没有,不过Java的我有个,你稍微转下用C++输出就Ok了
public class mul {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int i,j,s;
for(i=1;i<10;i++){
for(j=1;j<=i;j++){
s=i*j;
System.out.print(j+"*"+i+"="+s+" ");
}
System.out.println();
}
}
}
public class mul {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int i,j,s;
for(i=1;i<10;i++){
for(j=1;j<=i;j++){
s=i*j;
System.out.print(j+"*"+i+"="+s+" ");
}
System.out.println();
}
}
}
温馨提示:答案为网友推荐,仅供参考
第1个回答 推荐于2016-06-09
#include<iostream>
using namespace std;
void main()
{
int i,j;
for(i=1;i<=9;i++)
{ for(j=1;j<=i;j++)
cout<<j<<"*"<<i<<"="<<j*i<<" ";
cout<<endl;
}
}追问
using namespace std;
void main()
{
int i,j;
for(i=1;i<=9;i++)
{ for(j=1;j<=i;j++)
cout<<j<<"*"<<i<<"="<<j*i<<" ";
cout<<endl;
}
}追问
cout<<j<<"*"<<i<<"="<<j*i<<" ";
这句不是很懂~~~
输入j,星号当做乘号用的,输出i,输出结果输出空格,有什么不懂的呢,改成下面的看看
{cout<<j;
cout<<"*";
cout<<i;
cout<<"=";
cout<<i*j;
cout<<" ";}
输出空格不懂,为什么要输出空格啊~~~
追答不输出个空格,后面的内容就和前面的连在一起了
如这样1*2=22*2=4
第2个回答 2011-04-09
#include<iostream>
main()
{
int i,j;
for(i=1;i<=9;i++)
{
for(j=1;j<=i;j++)
cout<<i<<"*"<<j<<"="<<i*j;
cout<<endl;
}
}
main()
{
int i,j;
for(i=1;i<=9;i++)
{
for(j=1;j<=i;j++)
cout<<i<<"*"<<j<<"="<<i*j;
cout<<endl;
}
}
第3个回答 2011-04-09
#include "stdafx.h"
#include<iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
for (int k = 0; k <= 9; k++)
{
if (k == 0)
{
cout<<"*\t";
}
else
{
cout<<k<<"\t";
}
}
for (int i = 1; i <= 9; i++)
{
cout<<i<<"\t";
for (int j = 1; j <= i; j++)
{
cout<<i*j<<"\t";
}
cout<<"\n";
}
return 0;
}
#include "stdafx.h"
#include<iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
for (int k = 0; k <= 9; k++)
{
if (k == 0)
{
cout<<"*\t";
}
else
{
cout<<k<<"\t";
}
}
for (int i = 1; i <= 9; i++)
{
cout<<i<<"\t";
for (int j = 1; j <= i; j++)
{
cout<<i*j<<"\t";
}
cout<<"\n";
}
return 0;
}
#include<iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
for (int k = 0; k <= 9; k++)
{
if (k == 0)
{
cout<<"*\t";
}
else
{
cout<<k<<"\t";
}
}
for (int i = 1; i <= 9; i++)
{
cout<<i<<"\t";
for (int j = 1; j <= i; j++)
{
cout<<i*j<<"\t";
}
cout<<"\n";
}
return 0;
}
#include "stdafx.h"
#include<iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
for (int k = 0; k <= 9; k++)
{
if (k == 0)
{
cout<<"*\t";
}
else
{
cout<<k<<"\t";
}
}
for (int i = 1; i <= 9; i++)
{
cout<<i<<"\t";
for (int j = 1; j <= i; j++)
{
cout<<i*j<<"\t";
}
cout<<"\n";
}
return 0;
}