函数求解
欢迎进入我的C语言世界
题目
Problem Description
给出n,求f(n)。
Input
第一行一个正整数T,表示数据组数。 接下来T行,每行一个正整数n。 T<=20,n<=2015000000。
Output
对于每组数据,输出一行f(n)。
Sample Input
2
1
20150001
Sample Output
2015
20152014
答案
下面展示 实现代码
。
#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
int T;
int i, j;
while(scanf("%d",&T) != EOF)
{
for(i = 0; i < T; i++)
{
int n;
cin >> n;
if(n < 20150001)
{
cout << n + 2014 << endl;
}
else
{
cout << "20152014" << endl;
}
}
}
return 0;
}
本题感悟
本块内容可能来自课本或其他网站,若涉及侵权问题,请联系我进行删除,谢谢大家啦~
做完这题我有点疑问,我用递归RE了,万万没想到要找规律……
以上。