Java 双变量Floyd';s三角形图案
如何仅使用2个变量创建Floyd三角形 我使用这个逻辑,但它使用3个变量,但我只想用2创建它Java 双变量Floyd';s三角形图案,java,c++,Java,C++,如何仅使用2个变量创建Floyd三角形 我使用这个逻辑,但它使用3个变量,但我只想用2创建它 for(i=0;i<5;i++) { for(j=0;j<i;j++) { cout<<k; k++; } } (i=0;iFLOYD三角形模式的 #include <iostream> using namespace std; int main(){ int i=1,j=1,n; cout<<"inpu
for(i=0;i<5;i++)
{
for(j=0;j<i;j++)
{
cout<<k;
k++;
}
}
(i=0;iFLOYD三角形模式的
#include <iostream>
using namespace std;
int main(){
int i=1,j=1,n;
cout<<"input the value \"n\" upto which FLOYD's triangle needed to print \n"
cin>>n;
while(i<=n){ //here we use only two variable that is "i" and "j";
cout<< i <<" ";//if you are confused with pattern then comment these statement and use below statement.
//cout<<"* ";
if(i>=j*(j+1)/2){
cout<<"\n";
j++;
}
i++;
}
return 0;
}
#包括
使用名称空间std;
int main(){
int i=1,j=1,n;
coutn;
while(如果我想利用行数和列数来做这件事,我该怎么办。