作者executor1107 (我都在喇塞嘛><)
看板NSYSU-CSE97
標題[討論] HW7功課討論
時間Thu Dec 2 03:23:15 2004
我來開先例吧
#include<stdio.h>
#include<stdlib.h>
void main()
{
FILE *finput,*foutput;
int c,temp,i,total;
float avg,sum=0;
printf("Input the number of the numbers:");
scanf("%d",&total);
finput=fopen("input.txt","w+");
if(finput != NULL)
{
for(i=0;i<total;i++)
{
temp=rand();
printf(" %d \n",temp);
fprintf(finput,"%d\n",temp);
}
}
else
printf("Error 01:Couldn't open input.txt in writing phase.");
fclose(finput);
finput=fopen("input.txt","r+");
if(finput != NULL)
{
foutput=fopen("output.txt","w+");
if(foutput != NULL)
{
for(c=0;c<total;c++)
{
fscanf(finput,"%d",&temp);
fprintf(foutput,"%d\n",temp);
sum = sum + temp;
}
}
else
printf("Error 03:Couldn't open output.txt in writing phase.");
}
else
printf("Error 02:Couldn't open input.txt in reading phase.");
avg=sum/(float)total;
printf("The average of the numbers' is %0.2f\n",avg);
fprintf(foutput,"The %d numbers' average is %f\n",total,avg);
fclose(finput);
fclose(foutput);
}
大家討論討論吧
好的不好的都說一說
話說hw8的流程圖扯到sort bubble的部份我就喇塞過去了...
實在不想想...反正code部份是交給下星期的我去處理...
大家討論討論hw7的吧
hw8沒事也可以聊聊
這個版有一部份就是要這樣用的
--
......ID......
......I am a learning Dancer......
Shake my body through the music...
Dance with the Feel...
This is my ID......
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.117.186.180
1F:推 TheMinyen:我也是喇賽過去= = 140.117.199.8 12/02