You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
532 B
25 lines
532 B
#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;
|
|
} |