C++实验4

来源:互联网 发布:网络用语ddp是什么意思 编辑:程序博客网 时间:2024/05/21 07:12

一问题及代码丶

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

二丶运行结果

三丶心得体会

第四次上机的话,对C++语言相对来说比较熟悉了,但是这次的实验很难,一开始无从下手,慢慢找资料,慢慢完成。

四丶方法及总结

总的来说,要学会体会和运用循环语句

 

0 0