level 4
fox19891989
楼主
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
FILE *myfile;
int i, n, a;
myfile = fopen("numbers.txt", "w");
if (myfile == NULL)
{
printf("Unable to open the file");
}
else
{puts("This program will save a list of numbers to a text file.");
printf("How many numbers do u wish to save? ");
scanf("%d",&n);puts("Now, enter the numbers.");
for ( i=0; i<n; i++ ){
printf("> ");
fscanf(stdin,"%d",&a);
printf("U have %d remaining numbers to enter.\n",n-i-1);}
printf("U have entered all the numbers!");
fclose (myfile);
}
return 0;
}
代码在这,如何改进
2011年04月03日 15点04分
1
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
FILE *myfile;
int i, n, a;
myfile = fopen("numbers.txt", "w");
if (myfile == NULL)
{
printf("Unable to open the file");
}
else
{puts("This program will save a list of numbers to a text file.");
printf("How many numbers do u wish to save? ");
scanf("%d",&n);puts("Now, enter the numbers.");
for ( i=0; i<n; i++ ){
printf("> ");
fscanf(stdin,"%d",&a);
printf("U have %d remaining numbers to enter.\n",n-i-1);}
printf("U have entered all the numbers!");
fclose (myfile);
}
return 0;
}
代码在这,如何改进