为了账号安全,请及时绑定邮箱和手机立即绑定

请问我到底该用c++编写程序呢?

请问我到底该用c++编写程序呢?

C++
倚天杖 2019-07-08 16:04:18
请问我到底该用c++编写程序呢?
查看完整描述

4 回答

?
森林海

TA贡献2011条经验 获得超2个赞

double average(double &max, double &min, double a[], int num){
double sum = 0;
for(int i = 0; i < num; i++){
if(i==0){max=a[0]; min=a[0];}
else if(max<a[i] || min>a[i]){
if(max<a[i]) max=a[i];
if(min>a[i]) min=a[i];
}
sum+=a[i];
}
return (sum/num);
}





查看完整回答
反对 回复 2019-07-09
?
ABOUTYOU

TA贡献1812条经验 获得超5个赞

随便写的,没测试,每个都包含了下面的include
#inlcude <iostream>
using namespace std;
1.
int main(int argc, char *argv[])
{
for (char i = 32; i <= 127; i++)
{
cout << i << " ";
}
cout << endl;
return 0;
}
2.
int main(int argc, char *argv[])
{
char choice;
do
{
cout << "现在正在下雨吗?(Y/N)" << endl;
cin >> ch;
if ('Y' == ch) { cout << "现在正在下雨。" << endl; break; }
else if ('N' == ch) { cout << "现在没有下雨。" << endl; break; }
} while(true);
return 0;
}
3.
typedef struct _point
{
int x;
int y;
}point;
class Rectangle
{
public:
Rectangle() {}
Rectangle(const point &topleft, const point &bottomright) : m_topleft(topleft), m_bottomright(bottomright) {}

int size()
{
int ret = (topleft.x - bottomright.x) * (topleft.y - bottomright.y);
return ret > 0 ? ret : -ret;
}
private:
point m_topleft;
point m_bottomright;
};

int main(int argc, char *argv[])
{
point topleft = {10,10}, bottomright = {100,100};
Rectangle rect(topleft, bottomright);
cout << "size: " << rect.size() << endl;
return 0;
return 0;
}
4.
class Circle
{
public:
Circle() : m_radius(0.0) {}
Circle(const double &radius) : m_radius(radius) {}
double size()
{
return 3.14159265 * m_radius * m_radius;
}
private:
double m_radius;
};

int main(int argc, char *argv[])
{
double radius = 10.0;
Circle c(radius);
cout << "size: " << c.size() << endl;
return 0;
}






查看完整回答
反对 回复 2019-07-09
?
LEATH

TA贡献1936条经验 获得超6个赞

#include<bits/stdc++.h>
using namespace std;
int main(){
int num1=20060511;
printf("%d",num1);
return 0;
}



查看完整回答
反对 回复 2019-07-09
  • 4 回答
  • 0 关注
  • 346 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信