美文网首页
试题 算法训练 图形显示(C++)

试题 算法训练 图形显示(C++)

作者: melody_yuan | 来源:发表于2020-11-25 15:57 被阅读0次
  • 资源限制
    时间限制:1.0s 内存限制:512.0MB
  • 问题描述
      编写一个程序,首先输入一个整数,例如5,然后在屏幕上显示如下的图形(5表示行数):
      * * * * *
      * * * *
      * * *
      * *
      *

满分代码如下:

#include<iostream>
using namespace std;
int main(){
    int n,i,j;
    cin>>n;
    for(i=0;i<n;i++){
        for(j=n;j>i;j--){
            cout<<"* ";
        }
        cout<<endl;
    }
    return 0;
}

相关文章

网友评论

      本文标题:试题 算法训练 图形显示(C++)

      本文链接:https://www.haomeiwen.com/subject/pabtpktx.html