亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? teach.c

?? C語言的科學與藝術_第16個實驗程序源碼
?? C
字號:
/* * File: teach.c * ------------- * This program executes a simple programmed instruction course. * The course is specified by a data file containing all the * course information.  The data structures and the format of * the data file are described in Chapter 16. */#include <stdio.h>#include <string.h>#include <ctype.h>#include "genlib.h"#include "strlib.h"#include "simpio.h"/* * Constants * --------- * MaxQuestions          -- Maximum question number * MaxLinesPerQuestion   -- Maximum number of lines per question * MaxAnswersPerQuestion -- Maximum answers per question * EndMarker             -- String marking end of question text */#define MaxQuestions          100#define MaxLinesPerQuestion    20#define MaxAnswersPerQuestion  10#define EndMarker "-----"/* Data structures *//* * Type: answerT * ------------- * This structure provides space for each possible answer * to a question. */typedef struct {    string ans;    int nextq;} answerT;/* * Type: questionT * --------------- * This structure provides space for all the information * needed to store one of the individual question records. * Because this structure is large and it makes sense * to refer to it as a single entity, questionT is defined * as a pointer type. */typedef struct {    string qtext[MaxLinesPerQuestion+1];    answerT answers[MaxAnswersPerQuestion];    int nAnswers;} *questionT;/* * Type: courseDB * -------------- * This type is used to define the entire database, which is * a pointer to a record containing the title and an array of * questions. */typedef struct {    string title;    questionT questions[MaxQuestions+1];} *courseDB;/* Private function declarations */static courseDB ReadDataBase(void);static bool ReadOneQuestion(FILE *infile, courseDB course);static void ReadQuestionText(FILE *infile, questionT q);static void ReadAnswers(FILE *infile, questionT q);static FILE *OpenUserFile(string prompt, string mode);static void ProcessCourse(courseDB course);static void AskQuestion(questionT q);static int FindAnswer(string ans, questionT q);/* Main program */main(){    courseDB course;    course = ReadDataBase();    ProcessCourse(course);}/* Section 1 -- Functions to read the data file *//* * Function: ReadDataBase * Usage: ReadDataBase(); * ---------------------- * This function asks the user for a file name and reads * in the database for the course.  The file is formatted * as discussed in the section "Designing the external * structure" in Chapter 16. */static courseDB ReadDataBase(void){    FILE *infile;    courseDB course;    infile = OpenUserFile("Enter name of course: ", "r");    course = New(courseDB);    course->title = ReadLine(infile);    while (ReadOneQuestion(infile, course));    fclose(infile);    return (course);}/* * Function: ReadOneQuestion * Usage: while (ReadOneQuestion(infile, course)); * ----------------------------------------------- * This function reads in a single question from infile into the * course data structure.  As long as the complete question is * read successfully, this function returns TRUE.  When the end * of the file is encountered, the function returns FALSE. * Thus, the "Usage" line above reads the entire data file. */static bool ReadOneQuestion(FILE *infile, courseDB course){    questionT question;    string line;    int qnum;    line = ReadLine(infile);    if (line == NULL) return (FALSE);    qnum = StringToInteger(line);    if (qnum < 1 || qnum > MaxQuestions) {        Error("Question number %d out of range", qnum);    }    question = New(questionT);    ReadQuestionText(infile, question);    ReadAnswers(infile, question);    course->questions[qnum] = question;    return (TRUE);}/* * Function: ReadQuestionText * Usage: ReadQuestionText(infile, question); * ------------------------------------------ * This function reads the text of the question into the * question data structure, which must have been allocated * by the caller.  The end of the question text is signaled * by a line matching the string EndMarker. */static void ReadQuestionText(FILE *infile, questionT q){    string line;    int nlines;    nlines = 0;    while (TRUE) {        line = ReadLine(infile);        if (StringEqual(line, EndMarker)) break;        if (nlines == MaxLinesPerQuestion) {            Error("Too many lines");        }        q->qtext[nlines] = line;        nlines++;    }    q->qtext[nlines] = NULL;}/* * Function: ReadAnswers * Usage: ReadAnswers(infile, question); * ------------------------------------- * This function reads the answer pairs for the question * from the input file.  Each answer consists of a string * followed by a colon, followed by the number of the next * question to be read.  The end of the answer list is * signaled by a blank line or the end of the file. */static void ReadAnswers(FILE *infile, questionT q){    string line, ans;    int len, cpos, nextq, nAnswers;    nAnswers = 0;    while ((line = ReadLine(infile)) != NULL           && (len = StringLength(line)) != 0) {        cpos = FindChar(':', line, 0);        if (cpos == -1) Error("Illegal answer format");        ans = SubString(line, 0, cpos - 1);        nextq = StringToInteger(SubString(line, cpos+1, len-1));        q->answers[nAnswers].ans = ConvertToUpperCase(ans);        q->answers[nAnswers].nextq = nextq;        nAnswers++;    }    q->nAnswers = nAnswers;}/* * Function: OpenUserFile * Usage: fileptr = OpenUserFile(prompt, mode); * -------------------------------------------- * This function prompts the user for a file name using the * prompt string supplied by the user and then attempts to * open that file with the specified mode.  If the file is * opened successfully, OpenUserFile returns the appropriate * file pointer.  If the open operation fails, the user is * informed of the failure and given an opportunity to enter * another file name. */static FILE *OpenUserFile(string prompt, string mode){    string filename;    FILE *result;    while (TRUE) {        printf("%s", prompt);        filename = GetLine();        result = fopen(filename, mode);        if (result != NULL) break;        printf("Can't open the file \"%s\"\n", filename);    }    return (result);}/* Section 2 -- Functions to process the course *//* * Function: ProcessCourse * Usage: ProcessCourse(course); * ----------------------------- * This function processes the course supplied by the caller. * The basic operation consists of a loop that * *    (a) prints out the current question *    (b) reads in an answer *    (c) looks up the answer in the database *    (d) goes to a new question on the basis of that answer * * In this implementation, the variable qnum holds the * index of the question and the variable q holds the * actual question data structure.  The course always begins * with question #1, after which the order is determined by * the answers. */static void ProcessCourse(courseDB course){    questionT q;    int qnum;    string ans;    int index;    printf("%s\n", course->title);    qnum = 1;    while (qnum != 0) {        q = course->questions[qnum];        AskQuestion(q);        ans = ConvertToUpperCase(GetLine());        index = FindAnswer(ans, q);        if (index == -1) {            printf("I don't understand that.\n");        } else {            qnum = q->answers[index].nextq;        }    }}/* * Function: AskQuestion * Usage: AskQuestion(q); * ---------------------- * This function asks the question indicated by the questionT * specified by q.  Asking the question consists of displaying * each of the lines that comprise the question text. */static void AskQuestion(questionT q){    int i;    for (i = 0; q->qtext[i] != NULL; i++) {        printf("%s\n", q->qtext[i]);    }}/* * Function: FindAnswer * Usage: FindAnswer(ans, q) * ------------------------- * This function looks up the string ans in the list of answers * for question q.  If the answer is found, its index in the * answer list is returned.  If not, the function returns -1. * The function uses a simple linear search algorithm to look * through the array. */static int FindAnswer(string ans, questionT q){    int i;    for (i = 0; i < q->nAnswers; i++) {        if (StringEqual(ans, q->answers[i].ans)) return (i);    }    return (-1);}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品天美传媒沈樵| 中文字幕乱码久久午夜不卡 | 亚洲国产精品影院| 国产精品久久夜| 国产精品免费av| 中文字幕 久热精品 视频在线 | 久久精品国产免费看久久精品| 午夜欧美一区二区三区在线播放| 亚洲大片在线观看| 日本欧美一区二区三区| 麻豆国产欧美一区二区三区| 久久99精品国产.久久久久| 久久精品国产精品亚洲精品| 国产一区视频导航| 国产成人在线视频网站| 91丨porny丨户外露出| 欧美人体做爰大胆视频| 欧美理论片在线| 欧美电影免费观看高清完整版在线观看| 色悠悠亚洲一区二区| 成人免费视频一区| 亚洲国产高清在线观看视频| 亚洲自拍欧美精品| 亚洲视频在线观看一区| 欧美不卡一区二区三区四区| 综合久久久久综合| caoporn国产一区二区| 国产日韩欧美精品电影三级在线| 精品一区二区在线免费观看| 日韩免费视频一区二区| 另类欧美日韩国产在线| 日韩一区二区视频| 麻豆精品一区二区三区| 日韩精品综合一本久道在线视频| 午夜精品久久久久久久99樱桃| 欧美视频一区二| 亚洲国产综合色| 欧美美女一区二区在线观看| 日韩在线播放一区二区| 正在播放亚洲一区| 国产a精品视频| 亚洲素人一区二区| 欧洲av在线精品| 图片区日韩欧美亚洲| 欧美一区二区国产| 国产麻豆91精品| 国产精品久久777777| 欧洲国内综合视频| 青青草精品视频| 久久精品亚洲精品国产欧美 | 中文在线一区二区| 91原创在线视频| 亚洲影院理伦片| 在线播放欧美女士性生活| 美国十次了思思久久精品导航| 2021中文字幕一区亚洲| 成人黄色网址在线观看| 亚洲激情网站免费观看| 日韩一区二区三区四区五区六区| 国产一区二区不卡老阿姨| 中文字幕佐山爱一区二区免费| 色丁香久综合在线久综合在线观看| 五月激情综合色| 欧美国产在线观看| 欧美日韩一区二区三区高清| 精品一区二区三区在线播放视频 | 高清久久久久久| 亚洲猫色日本管| 91精品福利在线一区二区三区| 成人午夜视频福利| 天堂在线一区二区| 国产精品欧美精品| 欧美一区二区在线观看| 成人午夜视频网站| 美日韩一区二区三区| 亚洲色图在线看| 精品国产人成亚洲区| 欧美婷婷六月丁香综合色| 国产一区二区三区精品视频| 亚洲国产成人精品视频| 国产日韩高清在线| 91精品国产一区二区三区香蕉| av不卡在线观看| 精品亚洲porn| 日韩精品成人一区二区三区| 1024精品合集| 久久午夜国产精品| 日韩视频一区二区在线观看| 91久久国产最好的精华液| 国产麻豆精品久久一二三| 视频一区在线视频| 亚洲五月六月丁香激情| 亚洲欧洲无码一区二区三区| 久久免费偷拍视频| 欧美一区二区精美| 欧美裸体bbwbbwbbw| 色婷婷综合五月| 成人av网址在线| 国产精品乡下勾搭老头1| 免费在线成人网| 日韩中文字幕1| 亚洲6080在线| 亚洲一区中文在线| 亚洲综合色丁香婷婷六月图片| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ原创 | 色婷婷一区二区三区四区| 国产成人免费在线观看不卡| 国产在线视频一区二区| 黄色小说综合网站| 国内精品久久久久影院色| 美女网站在线免费欧美精品| 日韩电影网1区2区| 日本亚洲三级在线| 蜜桃久久久久久久| 久久 天天综合| 极品少妇一区二区三区精品视频| 男女男精品视频| 蜜臀av性久久久久蜜臀aⅴ四虎| 丝袜a∨在线一区二区三区不卡| 亚洲第一福利一区| 日本三级亚洲精品| 九色综合国产一区二区三区| 国产最新精品免费| 国产福利一区在线| 成人教育av在线| 91啪九色porn原创视频在线观看| 一本久久a久久精品亚洲| 色狠狠桃花综合| 6080yy午夜一二三区久久| 日韩欧美美女一区二区三区| 久久久久久**毛片大全| 国产精品久久久久久久久搜平片 | 亚洲制服欧美中文字幕中文字幕| 亚洲一二三四在线| 欧美aⅴ一区二区三区视频| 久久99国产精品成人| 高清日韩电视剧大全免费| 91在线精品一区二区三区| 欧美三片在线视频观看| 日韩精品一区二区三区四区视频 | 亚洲欧美另类图片小说| 亚洲一区二区美女| 美女免费视频一区二区| 成人免费毛片高清视频| 欧美无乱码久久久免费午夜一区 | 欧美亚洲综合一区| 日韩美女在线视频| 亚洲欧洲精品成人久久奇米网| 亚洲高清免费视频| 国产在线不卡一区| 日本道精品一区二区三区| 欧美一区二区日韩| 亚洲人成人一区二区在线观看| 日欧美一区二区| 不卡的av中国片| 91精品国产综合久久香蕉的特点| 中文乱码免费一区二区| 日韩中文字幕区一区有砖一区 | 国产肉丝袜一区二区| 亚洲国产精品视频| 风间由美性色一区二区三区| 欧美精品三级日韩久久| 国产精品久久久久婷婷二区次| 日韩主播视频在线| 91一区在线观看| 久久久美女毛片| 午夜精品福利一区二区三区av| 丁香五精品蜜臀久久久久99网站| 欧美唯美清纯偷拍| 国产精品乱码久久久久久| 美女视频网站黄色亚洲| 欧美日韩一区在线| 亚洲欧洲另类国产综合| 国产一区二区三区精品欧美日韩一区二区三区 | 色综合中文字幕| 国产欧美日韩卡一| 蜜臀av一级做a爰片久久| 色94色欧美sute亚洲线路二 | 日韩一级免费一区| 夜夜精品视频一区二区| 成人性色生活片免费看爆迷你毛片| 欧美一区二区三区免费| 一区二区三区不卡视频| av激情亚洲男人天堂| 国产视频在线观看一区二区三区| 免费观看日韩电影| 欧美高清视频在线高清观看mv色露露十八| 国产欧美日韩不卡| 国产福利精品导航| 2024国产精品| 国产尤物一区二区| 欧美精品一区二区三区视频 | 欧美一级日韩免费不卡| 午夜视频在线观看一区二区| 欧美性生活大片视频| 一区二区三区av电影| 欧美主播一区二区三区美女| 亚洲黄网站在线观看| 色综合久久中文综合久久牛| 亚洲人成亚洲人成在线观看图片|