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

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

?? teach.c

?? c語言開發方面的經典問題,包括源代碼.c語言開發所要注意的問題,以及在嵌入式等各方面的應用
?? 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一区二区三区免费野_久草精品视频
国产精品丝袜在线| 欧美调教femdomvk| 国产亚洲精品7777| 国产91精品一区二区麻豆亚洲| 欧美xfplay| 国产精品小仙女| 国产精品理论在线观看| 欧美最猛黑人xxxxx猛交| 无吗不卡中文字幕| 精品国产精品网麻豆系列| 国产91精品露脸国语对白| 亚洲色图另类专区| 51精品国自产在线| 国产一区二区精品久久91| 国产精品伦一区二区三级视频| 91丨porny丨中文| 日韩成人av影视| 国产日韩欧美综合在线| 91精彩视频在线观看| 日本特黄久久久高潮| 国产人伦精品一区二区| 欧美性淫爽ww久久久久无| 九色综合狠狠综合久久| 亚洲欧洲日产国码二区| 欧美精品亚洲一区二区在线播放| 激情综合网天天干| 亚洲一区免费在线观看| 欧美大片在线观看一区二区| 91蜜桃网址入口| 久久er99精品| 亚洲免费在线观看视频| 精品裸体舞一区二区三区| 97久久精品人人澡人人爽| 婷婷开心久久网| 国产精品美女久久久久久久| 欧美一区二区三区公司| 91麻豆精品秘密| 韩国av一区二区三区四区 | 色八戒一区二区三区| 日本不卡免费在线视频| 亚洲黄色小视频| 久久精品水蜜桃av综合天堂| 欧美日韩一级黄| 成人国产一区二区三区精品| 蜜臀av一区二区| 亚洲高清一区二区三区| 中文字幕一区二区三区色视频| 日韩欧美的一区| 精品视频在线视频| 成人h动漫精品一区二| 精品一区二区三区欧美| 午夜精品福利一区二区蜜股av| 亚洲色图欧洲色图| 中文字幕成人av| 久久无码av三级| 91精品国产入口| 欧美午夜精品一区二区三区| 97久久精品人人澡人人爽| 国产99久久久国产精品潘金网站| 韩国女主播一区二区三区| 无码av中文一区二区三区桃花岛| 一区二区三区四区蜜桃| 亚洲色图视频网站| 亚洲色图在线看| 亚洲欧洲av在线| 中文字幕视频一区二区三区久| 久久蜜桃av一区精品变态类天堂| 日韩欧美中文字幕一区| 91精品国产色综合久久| 欧美一区欧美二区| 91精品国产一区二区人妖| 欧美剧在线免费观看网站 | 成人性生交大片| 国产精品18久久久久久久网站| 奇米888四色在线精品| 水蜜桃久久夜色精品一区的特点| 亚洲成a人v欧美综合天堂| 午夜电影网一区| 日韩影院在线观看| 日日摸夜夜添夜夜添国产精品| 亚洲成av人片一区二区三区 | 国产亚洲一区二区在线观看| 精品国产成人在线影院 | 欧美激情艳妇裸体舞| 久久久久亚洲蜜桃| 国产欧美日韩激情| ...中文天堂在线一区| 一区二区三区精密机械公司| 午夜精品影院在线观看| 日韩电影在线观看一区| 精品日韩一区二区三区免费视频| 日韩久久久久久| 99久精品国产| 色欧美乱欧美15图片| 欧美在线一区二区| 日韩视频免费观看高清完整版在线观看| 日韩亚洲欧美综合| 国产午夜精品一区二区三区四区| 亚洲欧洲一区二区在线播放| 洋洋成人永久网站入口| 日韩影视精彩在线| 国产一区二区免费视频| av欧美精品.com| 欧美日韩精品一区二区| 精品国产精品一区二区夜夜嗨| 欧美国产精品一区二区| 亚洲国产精品天堂| 国产一区二区影院| 91精品福利在线| 精品国产乱码久久久久久闺蜜| 国产精品超碰97尤物18| 视频在线在亚洲| 国产福利视频一区二区三区| 一本到高清视频免费精品| 欧美电影精品一区二区| 成人免费在线视频| 麻豆91精品91久久久的内涵| 不卡视频一二三| 日韩一区二区精品葵司在线 | 日韩欧美第一区| 专区另类欧美日韩| 韩国精品久久久| 欧美日韩高清一区| 国产精品成人一区二区艾草| 免费成人在线观看| 日本精品一级二级| 久久影视一区二区| 午夜欧美2019年伦理| 成人高清视频在线观看| 精品人在线二区三区| 一区二区三区欧美日| 国产99一区视频免费| 91精品视频网| 一区av在线播放| 99久久精品费精品国产一区二区| 欧美xxxxx裸体时装秀| 午夜久久久久久久久久一区二区| 99国内精品久久| 国产欧美日韩精品a在线观看| 六月婷婷色综合| 欧美精品成人一区二区三区四区| 中文字幕亚洲区| 风间由美性色一区二区三区| 日韩三级中文字幕| 午夜欧美一区二区三区在线播放| 91在线丨porny丨国产| 国产清纯美女被跳蛋高潮一区二区久久w| 日韩成人免费电影| 精品视频在线免费| 亚洲免费视频中文字幕| 不卡在线视频中文字幕| 欧美国产精品v| 成人综合在线网站| 日本一区二区久久| 国产成人精品免费网站| 久久综合久久综合久久| 久久精品国产一区二区三区免费看| 欧美色老头old∨ideo| 一区二区三区在线播| 色综合久久中文综合久久97| 中文字幕一区二区视频| 97精品国产97久久久久久久久久久久| 国产婷婷色一区二区三区| 韩国三级电影一区二区| 久久一留热品黄| 国产经典欧美精品| 国产精品美女久久久久久2018| 成人av在线影院| 亚洲欧美日韩综合aⅴ视频| aaa国产一区| 一区二区三区**美女毛片| 在线观看视频欧美| 日韩有码一区二区三区| 日韩免费观看2025年上映的电影| 精品一区二区日韩| 久久网站最新地址| 成人免费黄色在线| 樱花影视一区二区| 在线不卡欧美精品一区二区三区| 日韩精品乱码免费| 26uuu亚洲综合色欧美| 国产传媒一区在线| 亚洲伦在线观看| 欧美日韩高清影院| 国产一区视频导航| 中文字幕日韩精品一区| 在线免费观看一区| 欧美aⅴ一区二区三区视频| 欧美大片顶级少妇| 成人激情免费视频| 亚洲不卡一区二区三区| 日韩免费福利电影在线观看| 国产高清精品在线| 亚洲一区在线观看视频| 日韩三区在线观看| 91美女片黄在线观看| 奇米888四色在线精品| 国产精品久久看| 7777精品伊人久久久大香线蕉完整版 | 欧美在线视频全部完|