• 1回复贴,共1

输出爱心的小程序,大家来优化一下。

取消只看楼主收藏回复

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
int main(){
int a,n,b,c,d,m;
cin>>n;
m=n/2;
for(a=1;a<=m;a++){
for(b=1;b<m-a+3;b++){
cout<<" ";
}
for(b=1;b<a*2;b++){
cout<<"*";
}
for(b=1;b<=n-a*2;b++){
cout<<" ";
}
for(b=1;b<a*2;b++){
cout<<"*";
}
cout<<endl;
}
for(a=1;a<=n;a++){
for(b=0;b<=a-1;b++)
cout<<" ";
for(b=1;b<=n*2-a*2+1;b++)
cout<<"*";
cout<<endl;
}
return 0;}


IP属地:北京1楼2015-07-25 22:03回复
    偏差是指的不能输偶数吗


    IP属地:北京4楼2015-07-27 08:04
    回复