#include<iostream>
using namespace std ;
class IDGenerator {
private:
static int s_nextID;
public:
static int getNextID(); // Fill in the keyword
};
int IDGenerator::s_nextID=0;// Fill in the statement
int IDGenerator::getNextID() { return s_nextID++; }
int main() {
int add = 0, count = 0;
cin >> count;
for (int i = 0; i < count; ++i){
add = add + IDGenerator::getNextID();
}
cout << add;
return 0;
}
Thanks
Happy Computing !
using namespace std ;
class IDGenerator {
private:
static int s_nextID;
public:
static int getNextID(); // Fill in the keyword
};
int IDGenerator::s_nextID=0;// Fill in the statement
int IDGenerator::getNextID() { return s_nextID++; }
int main() {
int add = 0, count = 0;
cin >> count;
for (int i = 0; i < count; ++i){
add = add + IDGenerator::getNextID();
}
cout << add;
return 0;
}
Thanks
Happy Computing !
No comments:
Post a Comment