程序代码:
6. #include <stdio.h> double func(double x) { return x*x - 6.5*x + 2; } void main() { double x = -3; printf(" x\t y\n"); for (int i = 0; i < 13; i++) { printf("%6.2lf\t%6.2lf\n", x, func(x)); x += 0.5; } return; } ------------------------------------------------------------------------------- 7. #include<stdio.h> int func(int x, int y) { return x*x + y*y; } int main() { int S = 0; for (int i = 1; i < 30; i++) { S += func(i, i + 1); } printf("%d", S); return 0; } ----------------------------------------------------------------------------- 8. #include <stdio.h> double f(int n) { double s = 0; for (int i = 0, j = 0; i < 2*n-1-n+1; i++,j++) { s += n + j; } return s; } int main() { int n; double S = 0; scanf("%d", &n); for (int i = 1; i <= n; i++) { S += f(i) / i; } printf("%lf", S); return 0; }