C语言题目2
//用C编写程序:对任意整数n,求f(n)。 //f(n)=3n**2+2f(n-1)+f(n-2)-5, n>1 //f(1)=1, n=1 //f(0)=2, n=0 //f(n)=0, n<0 #include"stdio.h" int f(int n) { if(n>1) { return 3*n*n+2*f(n-1)+f(n-2)-5; } else if(n==1) { return 1; } else if(n==0) { return 2; } else { return 0; } } int main() { int n; int result; printf("请输入一个整数,输入完成后敲击回车:"); scanf("%d", &n); result = f(n); printf("f(%d)= %d\n", n, result); return 0; }
2022年9月16日 16:40
Uttarakhand Board of School Education and various subject experts of the state have designed and suggested the Term1 & Term-2 Exam Solved Question Bank with Answers as UK Board 4th Class Model Paper 2023 with Mock Test and Practice Questions for All Languages and Subjects of the Course for SCERT & NCERT Syllabus. Uttarakhand Board Model Paper Class 4 Every Elementary Level Primary School 4th Standard student Studding in Government & Private Schools of the State & Central Board can download and Practice the Learning & Study Material along with UK Board STD-4 Question Paper 2023 Pdf to now the new exam scheme and that’s helps you to get top scores in all exams.