如何在C语言编程中开发100页教科书索引 [英] How I Can Develop A Index Of Textbook Of 100 Pages In C Programming

查看:89
本文介绍了如何在C语言编程中开发100页教科书索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我我的问题的解决方案...

Please give me the solution of my question...

推荐答案

嗯......第一遍可能看起来像

<设计并存储一个常用单词列表 - 你可能需要将它们存储在一个文本文件中并在程序开始时读取它们 - 我要包括'a','this'等 - 这些都是简单的单词,你会跳过



b)通读文字,将其标记为单词并跟踪页面#



c)如果这个词在(a)的'common'列表中,跳过它(否则见(d))



d)存储这个词,可能在字典中 - 我创建一个单词词典(作为字符串) - > struct(count as int,page#as int) - 计数可能对修剪单词列表和将简单单词添加回(a)中的列表有用..即它可能是手动/迭代



e)如果您的字典类已经排序,并且您希望按字而不是页面进行索引,那么您所要做的就是遍历它,打印单词,一行点,然后计数 - 如果没有,你可以做一个两步过程,迭代字典到一个结构数组,排序该数组,然后将其转储出格式良好的



你需要考虑适当的数据结构,在页面#或单词
well ... a first pass may look like

a) devise and store a list of 'common' words - you may need to store them in a text file and read them in at program start - I'd include 'a', 'this' etc - these are simple words you'll skip

b) read through the text, tokenising it into words & tracking the page #

c) if the word is in your 'common' list from (a), skip it (else see (d))

d) store the word, possibly in a dictionary - I'd create a dictionary of word (as string) -> struct (count as int, page # as int) - the count may be useful for pruning the word list and adding simple words back to the list in (a) .. ie it may be manual/iterative

e) if your dictionary class is sorted and you want the index by word rather than page, all you have to do is iterate through it, print the word, a row of dots, then the count - if not, you could do this as a two step process, iterate through the dictionary to a maybe an array of structs, sort that array, then dump it out nicely formatted

you'll need to think about appropriate data structures, wether to sort on page # or word

上排序

这篇关于如何在C语言编程中开发100页教科书索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆