猿问

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

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


倚天杖
浏览 347回答 4
4回答

森林海

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);}

ABOUTYOU

随便写的,没测试,每个都包含了下面的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;}

LEATH

#include<bits/stdc++.h>using namespace std;int main(){int num1=20060511;printf("%d",num1);return 0;}
随时随地看视频慕课网APP
我要回答