中南大學
《c++課程設計》設計報告
題目 c++課程設計
學生姓名
學號專業班級數學類0901
指導老師袁修貴
數學科學與計算技術學院
2023年6月
一、實驗目的、內容
1.使用者任意輸入乙個年份以及該年的1月1日是星期幾,而後再輸入該年的任意乙個月份,由程式負責在螢幕上按照你所設計的格式顯示出這乙個月的月曆。
思考:利用元年元月元日(即1年1月1日)是星期一的已知事實,可對程式進行改造,讓使用者僅輸入任意乙個年份和乙個月份,則程式就應按格式顯示出該年那乙個月的月曆。
2. 編寫程式,從鍵盤讀入乙個文字檔案名字(可帶路徑),為該檔案中的所有單詞建立乙個詞彙索引。按字母順序顯示所有單詞(僅一次),後面緊跟著它們所在的行號。
大寫與小寫字母被認為是相同的。例如,對於下列的輸入檔案:
to be or
not to be,
that is the question.
產生的詞彙索引如下:
be1 2
is3not2
or1question 3
that3
the3
to1 2
3.模擬計算器程式
問題描述
設計乙個程式來模擬乙個簡單的手持計算器。程式支援算術運算以及c(清除)、a(全清除)操作。
基本要求
程式執行時,顯示乙個視窗,等待使用者輸入,使用者可以從鍵盤輸入要計算的表示式,輸入的表示式顯示在視窗中,使用者鍵入』=』 符號後,視窗顯示出結果。
測試資料
程式輸入不少於5種不同的表示式進行測試。
實現提示
可定義乙個計算器類,該類包括兩個元件物件,乙個計算引擎和乙個使用者介面,使用者介面物件處理接受的鍵盤輸入資訊,並顯示答案,計算引擎物件對給出的資料執行相應操作,並儲存操作的結果。
二、實驗程式設計及結構
1、 需求分析
對需求的資訊進行模糊查詢
模擬電子辭典
模擬計算器
2、 設計結構
(1)#include
#include
int a[13] = ;
int main()
; //日曆中的星期
puts("please input the weekday of date month 1/day 1:");
scanf("%d",&n);
puts("please input the date you want:");
scanf("%d%d%d",&year,&month,&day);
if((year % 4 == 0 && year % 100 != 0)||year % 400 == 0)
a[2] = 29;
for(i=1;i days += a[i];
s = day + days;
if((s + n - 1) >= 7)
s = (s + n - 1) % 7;
else
s = s + n - 1;
printf("weekday:");
switch(s)
if((days +n)>= 7)
r = (days + n)%7;
else
r = days +n;
for(i = 0;i < 42;i++)
printf("%d\t",b[i]);
if(i > 5&&(i+1) % 7 == 0)
printf("\n");
}return 0;
}(2)#include
#include
#include
#include
using namespace std;
typedef struct _unit
unit;
int main()
unit temp;
int linenumber = 1;
while(!in.eof())
}in.close();
bool isin = false;
vector copy;
for (unsigned int i=0; i
}if (!isin)
copy.push_back(list[i].word);
} vector lineno;
for (unsigned int m=0; m
}lineno.push_back(0);
} int current=0;
for (unsigned int o=0; o
else
cout< }
cout< }
return 0;
}(3)#include
#include
#include
#include
#include
#include
#include
using namespace std;
istream* input; // pointer to input stream
int no_of_errors; // note: default initialized to 0
double error(const char* s)
enum token_value ;
token_value curr_tok = print;
double number_value;
string string_value;
token_value get_token()
while (ch!='\n' && isspace(ch));
switch (ch) {
case ';':
case '\n':
return curr_tok=print;
case '*':
case '/':
case '+':
case '-':
case '(':
case ')':
case '=':
return curr_tok=token_value(ch);
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
case '.':
input->putback(ch);
*input >> number_value;
return curr_tok=number;
default: // name, name=, or error
if (isalpha(ch)) {
string_value = ch;
while (input->get(ch) && isalnum(ch))
string_value += ch; // string_value.push_back(ch);
中南大學c課程設計報告
中南大學 高階程式設計實踐 c 課程設計報告 設計題目教學裝置管理系統 指導老師 設計者專業班級 設計日期 一課題的基本內容和要求 二程式功能簡介 三主體內容 1 設計分析 2 程式整體結構 3 部分模組的結構 4 相關模組源程式 5 操作方法 6試驗結果 7設計體會 8 參考文獻 一基本內容和要求...
中南大學EDA課程設計報告
中南大學 指導老師 張靜秋 姓名 梁雪林 學號 0909091925 專業班級 自動化0905 目錄一 設計內容簡介 2 二 設計要求 2 基本要求 2 提高部分要求 3 三 方案論證 整體電路設計原理 3 四 各個模組設計原理 4 4.1 分頻電路模組設計 5 4.2 秒計時器模組設計 7 4.3...
中南大學資料結構課程設計報告
資訊科學與工程學院 課程設計報告書 課程名稱資料結構 設計題目算術表示式求值 專業班級電子資訊工程1002 學號0909101123 姓名楊家駿 指導教師李登 2012年 7月 目錄 問題描述 基本要求 資料結構的設計 軟體模組結構圖 程式設計思想 程式流程圖 源程式 除錯分析 測試資料 使用者使用...