算法优化
哪位高手能帮忙把算法再优化一下:
int main()
{
int i,j,k;
cout << "Enter number of rows:";
cin >> i;
for(j=i;j>0;j--)
{
for(k=j-1;k>0;k--)
cout << '.';
for(k=0;k<i-j+1;k++)
cout <<'*';
cout << endl;
}
return 0;
}
哪位高手能帮忙把算法再优化一下:
int main()
{
int i,j,k;
cout << "Enter number of rows:";
cin >> i;
for(j=i;j>0;j--)
{
for(k=j-1;k>0;k--)
cout << '.';
for(k=0;k<i-j+1;k++)
cout <<'*';
cout << endl;
}
return 0;
}