可是现在我正写选修的论文,也是今晚要交。。。所以说杯具,如果不是时间问题我哪想在这苦求啊,自己的事当然尽力自己做啊!!!对不起,见笑了!
程序代码:#include <stdio.h>
#include <string.h>
int fib(int n) {
int start1 = 1, start2 = 1, temp, i = 2;
while(i++ < n) {
temp = start1 + start2;
start1 = start2;
start2 = temp;
}
return n == 0 ? 0 : start2;
}
void problem1() {
int n, i;
FILE * fp = fopen("testdata", "w");
scanf("%d", &n);
fprintf(fp, "%d", fib(1));
for(i = 1; i < n; i++)
fprintf(fp , ", %d", fib(i + 1));
fclose(fp);
}
void problem2() {
FILE * fp = fopen("testdata", "r");
int num;
fscanf(fp, "%d", &num);
num % 2 || printf("%d ", num);
while(fscanf(fp, "%*c%d", &num) != EOF)
num % 2 || printf("%d ", num);
fclose(fp);
}
void problem3() {
FILE * fp = fopen("testdata", "r");
char words[31], test_words[31];
int count = 0;
scanf("%s", words);
while(fscanf(fp, "%s", test_words) != EOF)
strcmp(words, test_words) || count++;
printf("%d\n", count);
fclose(fp);
}
int main(void) {
// problem1();
// problem2();
// problem3();
return 0;
}这种代码应该自己写,反正我写起很蛋疼。







