首页 > 试题广场 >

实现一个多行输出的程序,输出内容为: *

[问答题]
实现一个多行输出的程序,输出内容为:
*
***
*****
*******
*****
***
*



推荐
//========================================
//EX0102.cpp
//========================================
#include<iostream>
using namespace std;
//------------------------------------------------------------------------
int main() {
    cout<<"    *\n";
    cout<<"   ***\n";
    cout<<"  *****\n";
    cout<<" *******\n";
    cout<<"  *****\n";
    cout<<"   ***\n";
    cout<<"    *\n";
}//=======================================

发表于 2018-05-07 20:31:13 回复(1)
NSM头像 NSM
cout<<"*"<<endl<<"***"<<endl<<"*****"<<endl<<"*******"<<endl<<"*****"<<endl<<"***"<<endl<<"*";
return 0;

发表于 2018-09-25 17:43:47 回复(0)
#include<iostream>
using namespace std;
int main(){
cout<<"*\n"<<"***\n"<<"*****\n"<<"*******\n"<<"*****\n"<<"***\n"<<"*\n";
}

发表于 2020-02-01 21:05:46 回复(0)
#include<iostream>
using namespace std;
int main(){
    for(int i=0;i<4;i++){
        for(int j=0;j<1+2*i;j++){
            cout<<"*";
        }
        cout<<endl;
    }
    for(int i=0;i<3;i++){
        for(int j=2*i;j<5;j++){
            cout<<"*";
        }
        cout<<endl;
    }

}
发表于 2020-07-31 11:19:10 回复(0)
#include <iostream>

int main(){
    char x='*';
    int i,j;
    for(i=1;i<=7;i++){
        
        for(j=1;j<=i;j++){
             
            std::cout<<x; 
        }
        std::cout<<"\n";
        i=i+1;
    }
    for(i=1;i<=6;i++){
        for(j=5;j>=i;j--){
            std::cout<<x;
        }
        std::cout<<"\n";
        i=i+1;
    }
    return 0;

发表于 2019-03-18 10:59:59 回复(0)
#include <iostream>
using namespace std;
int main()
{
    int i=1,j;
    while (i <= 4) {
    for (j = 0; j < 2 * i - 1; j++) {
        cout << '*';
        }
            cout << endl;
            i++;
    }
    while(i>0){
        for (j = 0; j < 2 * (i-2) - 1; j++) {
            cout << '*';
        }
        cout << endl;
        i--;
    }
    return 0;
}
发表于 2018-06-07 23:36:56 回复(0)
#include<iostream>

int main()
{
    std::cout<<"   *   \n";
    std::cout<<"  ***  \n";
    std::cout<<" ***** \n";
    std::cout<<"*******\n";
    std::cout<<" ***** \n";
    std::cout<<"  ***  \n";
    std::cout<<"   *   \n";
    return 0;
}//the stupidest way 
发表于 2018-06-02 10:10:43 回复(0)
#include<iostream>

using namespace std;

void print(int count, char c);

int main(){
    int rowCount, count;
    char c;
    cout<<"please input count of rows: ";
    cin>>rowCount;
    cout<<"please character used to show: ";
    cin>>c;
    for(int i  =0; i < rowCount; i++){
        count = (i<=rowCount/2?2*i+1:2*(rowCount/2*2-i)+1);
        print(count, c);
//        if(i <= rowCount/2){
//            print(2*i+1, '*');
//        }else{
//            print(2*(rowCount/2*2-i)+1, '*');
//        }
    }

    return 0;
}

void print(int count, char c){
    for(int i = 0; i < count; i++){
        cout<<c; 
    }
    cout<<endl; 
}
编辑于 2018-06-01 20:02:40 回复(0)
include<iostream>
using namespace std;
int main()
{
cout<<"*"<<endl;
cout<<"***"<<endl;
cout<<"*****"<<endl;
cout<<"*******"<<endl; cout<<"*****"<<endl;
cout<<"***"<<endl;
cout<<"*"<<endl;
return 0;
}

编辑于 2018-05-16 13:29:56 回复(0)