#include <iostream>
using namespace std;
class circle {
int radius;
public:
circle();
~circle() {}
void setradius(int r) { radius = r; }
double getarea() { return 3.14 * radius * radius; }
};
circle::circle() {
radius = 1;
}
int main() {
cout << "생성하과 하는 원의 개수";
int n, radius;
cin >> n;
if (n <= 0)return 0;
circle* parray = new circle[n];
for (int i = 0; i < n; i++) {
cout << "원" << i + 1 << ":";
cin >> radius;
parray[i].setradius(radius);
}
int cout = 0;
circle* p = parray;
for (int i = 0; i < n; i++) {
cout << p->getarea() << ' ';
if (p->getarea() >= 100 && p->getarea() <=200)
count++;
p++;
}
cout << endl << "면적이 100에서 200 사이인 원의 개수는" << count << endl;
delete [] parray;
}
- dc official App
오류를 올려..
제발 디버깅좀하고 올려
교과서 그대로 안베꼈기 때문.
근데 오랜만이다. 프로그래밍 안접었네
생성하과 하는 원의 개수 -> 생성하고자하는 원의개수로 바꾸셈
그건 오류랑 상관없는거같은데
컴파일 뭘로함?