简易图形输出
时间: 1ms 内存:128M
描述:
输出如下图形
*******
******
*****
****
***
**
*
输入:
无输入
输出:
输出以下图形
*******
******
*****
****
***
**
*
示例输入:
示例输出:
*******
******
*****
****
***
**
*
提示:
参考答案(内存最优[0]):
#include<stdio.h>
int main()
{
printf("*******\n******\n*****\n****\n***\n**\n*\n");
}
参考答案(时间最优[0]):
#include <iostream>
#include<iomanip>
#include<math.h>
using namespace std;
class XY_Qquation
{
public:
XY_Qquation(double aa,double bb,double cc):a(aa),b(bb),c(cc){}
double dirt();
void output();
private:
double a,b,c;
};
double XY_Qquation::dirt()
{
return (b*b-4*a*c);
}
void XY_Qquation::output()
{
double d=dirt();
cout<<setiosflags(ios::fixed)<<setprecision(2);
if(d<0)
{
cout<<-b/(2*a)<<"-"<<sqrt(-d)/(2*a)<<"i"<<" "<<-b/(2*a)<<"+"<<sqrt(-d)/(2*a)<<"i"<<endl;
}
else if(d==0)
{
cout<<b/(2*a)<<endl;
}
else if(d>0)
{
cout<<(-b-sqrt(d))/(2*a)<<" "<<(-b+sqrt(d))/(2*a)<<endl;
}
}
int main()
{
double a,b,c;
cin>>a>>b>>c;
XY_Qquation Q(a,b,c);
Q.output();
return 0;
}
题目和答案均来自于互联网,仅供参考,如有问题请联系管理员修改或删除。
