- #include <iostream>
- using namespace std;
- int main()
- {
- float a, b, c;
- cin>> a>> b>> c;
- cout <<((a + b + c)/3 < 8.3 ? "Yes" : "No") << endl;
- return 0;
- }
第 2 题
分析:
本题考斐波那契数列.
- #include <iostream>
- using namespace std;
- int fibo(int n)
- {
- if(1 == n || 2 == n)
- {
- return 1;
- }
- return fibo(n - 2) + fibo(n - 1);
- }
- int main()
- {
- int n;
- cin>> n;
- cout <<fibo(n) << endl;
- return 0;
- }
第 3 题
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- cin>> n;
- int i, j;
- for(i = 1; i <= n; i++)
- {
- for(j = 1; j <= n - i; j++)
- {
- cout << ' ';
- }
- for(j = 1; j <= 2 * i - 1; j++)
- {
- cout << '*';
- }
- cout << endl;
- }
- for(i = 1; i <= n; i++)
- {
- for(j = 1; j <= n - 1; j++)
- {
- cout << ' ';
- }
- cout << '*' << endl;
- }
- return 0;
- }
来源: http://www.jianshu.com/p/9258ac391432