| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1826 人关注过本帖
标题:求助C语言高手!BT学校居然布置英文作业~
只看楼主 加入收藏
只为流浪
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-11-27
收藏
 问题点数:0 回复次数:14 
求助C语言高手!BT学校居然布置英文作业~
[bold][underline]Week 10 Exercises – [/underline][/bold][bold][underline][font=TimesNewRoman]File Input/Output[/underline][/bold][/font]
[underline]Objectives[/underline][font=Times New Roman]Design and write programs that read and write data to/from files.[/font]
[underline]Tutorial Assessment[/underline]The students are required to do [bold][underline]ALL[/underline][/bold] exercises. [font=TimesNewRoman]All assessed exercises need to be submitted in the Assessment section of this module under ICE. Include comment lines to explain the code in detail (no design document is needed).[/font]
[underline]Deadlines[/underline][font=TimesNewRoman]The deadline for submitting the exercises is: [bold][italic]Thursday 6th December 2007 at 4pm.[/italic][/bold][bold][/bold][/font]
[bold] [/bold]

[align=center][bold][font=Wingdings]F[/font][/bold][bold][underline]Assessed exercises: 1, 2 & 3[/underline][/bold]

[/align]
[font=Times New Roman] [/font]
[underline]Exercise 1 (3 points)[/underline]
[font=TimesNewRoman]Write a file copy program that copies an existing file into another file. The program should ask the user to enter the source file name and destination file name. The file copy should be performed in [italic]binary[/italic] mode. Use [italic]fseek()[/italic]
to move within the source file and [italic]ftell()[/italic]
to determine the size of the file (if needed). Read the data from the source file and write the values read in the destination file in a [italic]loop[/italic]. Read and write data in blocks of [italic]1024 bytes[/italic].[/font]

[font=Times New Roman] [/font]
[underline]Exercise 2 (3 points)[/underline]
[font=TimesNewRoman]The following program reads from a [bold]text file [/bold]containing numeric data stored in columns separated by one blank space. Write the code and compile it on your computer. Create a text file called [bold]myfile.txt [/bold]containing a few columns (3[/font][font=Symbol]?[/font][font=Times New Roman]5 for example) of numeric data (real numbers) and test the program.[/font]
[bold][font=Times New Roman]#include <stdio.h>[/font][/bold]
[bold][font=Times New Roman]int main(void)[/font][/bold]
[bold][font=Times New Roman]{[/font][/bold]
[bold][font=Times New Roman]FILE *fp;[/font][/bold]
[bold][font=Times New Roman]double val;[/font][/bold]
[bold][font=Times New Roman]char ch;[/font][/bold]
[bold][font=Times New Roman] [/font][/bold]
[bold][font=Times New Roman]fp = fopen("myfile.txt","r");[/font][/bold]
[bold][font=Times New Roman]do{[/font][/bold]
[bold][font=Times New Roman]fscanf( fp, "%lf", &val );[/font][/bold]
[bold][font=Times New Roman]ch = getc(fp);[/font][/bold]
[bold][font=Times New Roman]printf(" %lf",val);[/font][/bold]
[bold][font=Times New Roman]if ( ch=='\n' || ch==EOF )[/font][/bold]
[bold][font=Times New Roman]printf("\n");[/font][/bold]
[bold][font=Times New Roman]} while ( ch != EOF );[/font][/bold]
[bold][font=Times New Roman]fclose(fp);[/font][/bold]
[bold][font=Times New Roman]return 0;[/font][/bold]
[bold][font=CourierNewPS-BoldMT]}[/bold][bold][/bold][/font]
[font=TimesNewRoman]Analyse the code and include comment lines explaining how the program achieves its task. Modify the code so that the program additionally creates a new text file where it stores only the integer part (discard the factionary part) of the real numbers stored in [bold]myfile.txt[/bold]. The new file should write data in the same format (3[/font][font=Symbol]?[/font][font=Times New Roman]5 with columns separated by space) as the original file. Include statements to check if the file was opened and closed successfully. Submit only the final, commented code.[/font]
[font=Times New Roman] [/font]
[font=Times New Roman] [/font]
[underline]Exercise 3 (4 points)[/underline]
[font=Times New Roman]Create a text file containing 20 rows of 20 integers separated by spaces. The integers should be in the range 0-9 and separated by spaces. Write a program that reads the contents into a 20[/font][font=Symbol]?[/font][font=TimesNewRoman]20 (two dimensional) array of int[/font]. [font=TimesNewRoman]The program then should use this array to initialize a 20x21 array of char by associating each integer from 0 to 9, with a character from ‘A’ to ‘J’. For example, 0 could be associated with ‘A’, while 9 with ‘J’. The 21st character on each line in the array of char should be the null character ‘\0’, making the array an array of 20 strings. Have the program display the resulting (picture) array of char (printing row-by-row the strings) on [italic]screen[/italic], and also write it in into a [italic]text file[/italic].[/font]
搜索更多相关主题的帖子: C语言 作业 学校 英文 
2007-12-03 15:06
永夜的极光
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:2721
专家分:1
注 册:2007-10-9
收藏
得分:0 
又是鸟文,继续54

cosdos再来给google一下

从BFS(Breadth First Study)到DFS(Depth First Study)
2007-12-03 15:39
C语言的深度
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:卡特的怀抱
等 级:版主
威 望:1
帖 子:9577
专家分:19
注 册:2007-10-22
收藏
得分:0 
我也看着晕呢  这都是什么意思

用代码打出楼房...用编程编出幸福...
2007-12-03 15:42
wubizao
Rank: 1
来 自:荆州长大电信
等 级:新手上路
帖 子:223
专家分:0
注 册:2006-6-24
收藏
得分:0 
至少单词认得我....

在路上走,看见了C,从此爱上了她
2007-12-03 15:55
Uc-Sun
Rank: 1
等 级:新手上路
帖 子:24
专家分:0
注 册:2007-11-28
收藏
得分:0 
[Google 上翻译如下 ]

10周练习-文件输入/输出
objectivesdesign写程式阅读和书写数据/从档案。
补习assessmentthe学生须尽一切演习。所有评估演习须提交在评估一节本单元下的冰毒。包括评论线解释代码详细(没有设计文件是必需的) 。
deadlinesthe截止日期前提交演习的是:周四2007年12月6日下午四时。

评估演练: 1 , 2及3


演习1 ( 3分)
写一个文件拷贝程序拷贝一个现有的文件到另一个文件。该计划应要求用户输入源文件名和目的地的档案名称。该文件的副本应在二进制模式。使用fseek ( )操作
迁移的源文件和ftell ( )
,以确定文件的大小(如需要) 。经过数据从源文件,并写值改为在目的地文件读入一个环路。阅读和书写数据块1024字节。

演习2 ( 3分)
以下节目内容,从一个文本文件中含有数字数据储存在栏目隔开的一个空白。写代码,并编译它在您的计算机上。创建一个文本文件名为myfile.txt含有几个栏目( 3'5为例)的数字数据(实数) ,并检验程序。
#include <stdio.h>
int main(void)
{
FILE *fp;
double val;
char ch;
fp = fopen("myfile.txt","r");
do{
fscanf( fp, "%lf", &val );
ch = getc(fp);
printf(" %lf",val);
if ( ch=='\n' || ch==EOF )
printf("\n");
} while ( ch != EOF );
fclose(fp);
return 0;
}
 分析代码,其中包括评论线解释如何把节目达到其任务。修改代码,使该节目还创造了一个新的文本文件,它存储的唯一整数部分(抛弃factionary部分)的真实号码储存在myfile.txt 。新的档案应当写入资料的格式相同( 3'5与柱分离,由用地) ,作为原始档案。包括报表,以检查是否该文件被打开和关闭成功。只提交最后,评论守则。

演习3 ( 4分)
创建一个文本文件载有20排20整数隔着位。该整数应在射程0-9和失散的,由用地。写程式读取内容成为一个20'20 (二维)的数组int 。然后程序应利用这个数组初始化1 20x21阵列煤焦所缔每一个整数,从0至9 ,同一个字符由' a '到' j ' 。举例来说, 0可与' ' ,而9号' j ' 。 21字符每条生产线在数组煤焦应该是无效字符' \ 0 ' ,使数组的数组20弦乐团。有节目汇演由此产生(图)阵列煤焦(印刷行,由行弦)在屏幕上,也不宜写入到一个文本文件。

COS-DOS
2007-12-03 16:01
kidd2005
Rank: 1
等 级:新手上路
帖 子:193
专家分:0
注 册:2007-11-2
收藏
得分:0 
恐怕LZ要先翻譯了再拿出來問啦~~畢竟編程強英文也強的人實在太少了~

潜心苦C,却发觉百C不得其解啊~
2007-12-03 16:18
lonmaor
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:郑州
等 级:版主
威 望:75
帖 子:2637
专家分:6423
注 册:2007-11-27
收藏
得分:0 
我简单翻译了一下:
Exercise 1
写一个文件复制程序用于复制一个已存在的文件到另一个文件。程序询问用户输入源文件名和目标文件名。文件复制的操作以二进制模式执行。使用fseek()函数来移动源文件中的内容,使用ftell()函数判断文件尺寸。用一个循环实现:读取源文件中的数据,然后写入到从目标文件中读取的值。使用1024字节大小的块读写数据。

Exercise 2
下面的程序从一个包含数字信息且以空格字符分割列的文本文件读取数据。在你的电脑中输入代码并编译程序。创建一个名为myfile.txt的文本文件包含若干行的数字数据然后调试程序。

【程序块略】
分析代码并使用注释行解释程序如何实现。修改代码使程序建立一个新的文本文件,使其存放实数的整数部分(抛弃小数部分)。新文件以与源文件相同的格式输出数据。包含判断文件打开/关闭是否成功的语句。提交编译成功的代码。

Exercise 3
建立一个文本文件包含20行每行20个以空格分割的整数。整数范围是0~9且以空格符分割。写一个程序读取一个20x20的二维整数数组。程序使用此数组来初始化一个20x21的字符型数组,方法是将0~9分别用A~J代替。例如,0用'A'代替,9用'J'代替,每行的最后一个字符写入'\0',也就是说每行都是一个c-style字符串。让程序输出char二维字符数组(一行一行的输出c-style字符串),在屏幕上显示运行结果,同时将结果输出到一个文本文件。
2007-12-03 16:27
jackly
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2007-12-1
收藏
得分:0 
牛人在哪里?
2007-12-03 23:16
只为流浪
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-11-27
收藏
得分:0 
唉....我们学金融的根本用不到C语言,但英国来的教务长还是坚持开设这门课,我都无语了,还望高手哥哥姐姐们指点啊~~
2007-12-04 03:03
dengll23
Rank: 1
等 级:新手上路
帖 子:70
专家分:0
注 册:2007-3-22
收藏
得分:0 
题目其实不难,楼主自己写吧
2007-12-04 12:30
快速回复:求助C语言高手!BT学校居然布置英文作业~
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016144 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved