25 lines
532 B
C++
25 lines
532 B
C++
#include <iostream>
|
|
using namespace std;
|
|
int n, cnt;
|
|
int f(int n) {
|
|
if (n == 2)
|
|
cnt = 2;
|
|
else if (n == 4)
|
|
cnt = 4;
|
|
else if (n == 5)
|
|
cnt = 3;
|
|
else if (n == 7)
|
|
cnt = 3;
|
|
else if (n % 3 == 0)
|
|
cnt = n / 3;
|
|
else if (n % 3 == 1)
|
|
cnt = (n - 7) / 3 + 3;
|
|
else if (n % 3 == 2)
|
|
cnt = (n - 5) / 3 + 3;
|
|
return cnt;
|
|
}
|
|
int main() {
|
|
for (int i = 2; i <= 100; i++)
|
|
cout << "i=" << i << ",fan=" << f(i) << endl;
|
|
return 0;
|
|
} |