Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
楼主: 丧送狂曲
打印 上一主题 下一主题

c++ 中级/中下级程式(计算学生分数grade)

[复制链接]

26

主题

1

好友

2082

积分

白金长老

Rank: 10

11#
发表于 2009-3-1 05:30 PM |只看该作者

回复 #10 Cougar 的帖子

能不能说下题目内容


回复

使用道具 举报

11

主题

0

好友

1584

积分

白银长老

Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9

12#
发表于 2009-3-1 06:08 PM |只看该作者
之前叫我们做 Crossword puzzle,8x8 的 othello,然后 text compressor。
现在的 part 1, 给你看吧
TCS1011 Data Structures and Algorithms
Trimester 3, Session 2008/2009
Faculty of Information Technology
Multimedia University
ASSIGNMENT
ADT for Relational Database Table
1. Title
Implement an ADT for a relational database table using C++.
2. Deadline
To be submitted via email to workjudge@gmail.com by the milestone deadlines set in lecture plan.
3. Grouping
To be done individually.
4. Objective
The objective of this assignment is to test the skill of students in creating a table ADT using the
C++ programming language. The table ADT must be able to support the use of SQL-like
commands to create tables, modify data and query data. The use of STL is not allowed for this
assignment.
5. Milestone 1
a. Introduction
For this milestone, create a C++ program which can read and execute INSERT and
SELECT commands from a text file for a table called Menu. The relation schema of Menu is
Menu( id, name, description, price)
as shown in the table below. The Menu table can contain up to a maximum of 100 tuples. The
domain of each attribute is either character string of 1 to 40 characters or number in the range from
-999999.99 to 999999.99.
Attribute Domain
id string (4)
name string (15)
description string (40)
price number
Note:
string(n) means a character string with a maximum of n characters.
number means a number from -999999.99 to 999999.99.
Using an example to illustrate the requirements, let's assume the text file “menu.sql”
contains the following commands and your C++ program has the name “database.exe”.
// menu.sql
INSERT INTO menu (id, name, description, price)
VALUES (P001, “Dinner Plate”, “Side order and 3 pieces of chicken”, 9.20);
INSERT INTO menu (id, name, description, price)
VALUES (P002, “Lunch Plate”, “Side order and 2 pieces of chicken”, 7.80);
INSERT INTO menu (id, name, description, price)
VALUES (S003, “Potato Snack”, “100g of potato slices”, 3.00);
INSERT INTO menu (id, name, description, price)
VALUES (B004, “Family Bucket”, “Drinks, side order and 9 pcs of chicken”,
25.00);
SELECT * FROM menu;
Executing your program with the command
prompt> database menu.sql
your program should displays the following result on screen.
MENU
----------------------------------------------------------------------------------
| ID | NAME | DESCRIPTION | PRICE |
----------------------------------------------------------------------------------
| P001 | Dinner Plate | Side order and 3 pieces of chicken | 9.20 |
| P002 | Lunch Plate | Side order and 2 pieces of chicken | 7.80 |
| S003 | Potato Snack | 100g of potato slices | 3.00 |
| B004 | Family Bucket | Drinks, side order and 9 pcs of chicken | 25.00 |
---------------------------------------------------------------------------------
4 rows selected.
The width of each column displayed is the maximum width specified for each corresponding
attribute. In the case of Menu, the widths are 4+2 characters, 15+2 characters, 40+2 characters and
10+2 characters for id, name, description and price respectively.
If there are no data in the table Menu, your program should display
MENU
0 rows selected.
The sequence of INSERT statements and SELECT statements can be of any order. For
example, the sequence of statements can start with four INSERT statements followed by two
SELECT statements, and then followed by another 2 INSERT statements Your program should
support any combination of INSERT and SELECT statements.
b. INSERT Statement
In addition to the example your program must be able to support NULL data for the
INSERT statement except for the first attribute (id) which is the primary key. The following
statement is a valid INSERT statement for your program.
INSERT INTO menu (id, name, description, price)
VALUES (001, “Breakfast Meal”, NULL, NULL);
*Note: NULL's should be displayed as blanks when a SELECT statement is executed.
You can assume that the INSERT statement always has the four attributes (id, name, description
and price) in a correct sequence.
c. SELECT Statement
The SELECT statement for this milestone is a greatly simplified version of standard SQL.
Your program only needs to support the * wild card or a sequence of attribute names for indicating
the attributes to display, . For example,
SELECT id, price, name FROM menu;
SELECT name FROM menu;
are valid statements to be supported while
SELECT id, price + 3 FROM menu;
SELECT name, name, id FROM menu;
are invalid statements which should be rejected.
For the WHERE part your program only needs to support one condition which contains
only one operator, the = (equal) operator. For example,
SELECT price, name
FROM menu
WHERE name = “Potato Snack”;
SELECT name, id
FROM menu
WHERE price = 5.00;
are valid statements to be supported while
SELECT id, price
FROM menu
WHERE price > 5.00;
SELECT name, id
FROM menu
WHERE ( name = “Potato Snack” ) AND ( id = “S003” );
are invalid statements which should be rejected.
The syntax of the SELECT syntax is summarized in the table below.
Part of the SELECT statement Supported command structure
SELECT * or a sequence of attribute names
FROM this is always menu as there is only one table
WHERE supports only the = operator for only one condition.
7. Evaluation Criteria
Milestone 1 Mark Sheet
Max Marks
1. Features
a. SELECT statement is supported 1
b. INSERT statement is supported 1
TOTAL 2
8. Submission instruction
a. Create a folder in the following format:
LECTURESECTION_M1_FULLNAME
b. Place ONLY your files of formats .cpp and .h in the folder. DO NOT place your
.exe file in the folder.
c. Zip your folder with the 7Zip program.
2. Send the zipped file to workjudge@gmail.com before the deadline. The email title should
be “TCS1011_TC101_M1_Submission”
a. Late submission will be detected through the system clock.
3. Additional Information
a. 50% of the allocated marks will be deducted if the submission instructions are not
followed.
b. You are expected to make sure that your code is easily readable. Pay attention to
indentation.
c. In your .cpp and .h files, insert appropriate comments to help others to understand
your code.
d. For ALL your .cpp and .h files, insert the following info at the header:


回复

使用道具 举报

11

主题

0

好友

1584

积分

白银长老

Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9

13#
发表于 2009-3-1 06:10 PM |只看该作者
我做到这里就不会做了:

#include<iostream>
#include<fstream>
using namespace std;

//string MAX = 99999;
int i=0;

string token;


int main()
{

    string loading;
   // string word_counter;

     fstream input;
    // char temp[999999];

     input.open("test.txt",fstream::in);

     while(!input.eof())
    {
        getline(input,loading);
        for(int z=0;z<loading.length();z++)
        {

//           if(isalpha(loading[z])||(isdigit(loading[z]))||(loading[z]=='\''))
//            {
//                    i++;
//                token+=loading[z];       // token is word, buffer is 1 sentence = store sentence to word
//            //    word_counter++;   // go to next word
//
//           }
             if(loading[z] == ' ')          // store space to word
            {
               // i++;
                token=loading[z];
                i++;
            }

             if(loading[z] == ' ')          // store space to word
            {
                i++;
                token=loading[z];
               // i++;
            }

            if(loading [z] == ',' || loading[z] == '(' || loading [z] == ')')
            {
                // word_counter++;
                i++;
                token=loading[z];
               // i++;

            }


           token = loading [z];
            i++;


       // token="\n";    // skip enter

    }
    i++;
//      cout << token [6] << token[8] << token [10] << token[11] << token[12] << token[15] << token[16] << token [17]
//               << token [18] << token [19] << token [20];

     for (int k = 0; k<i; k++)
     {
          cout << token[k];
     }
     // i++;

    return 0;

}
}

能不能指点指点啊?


回复

使用道具 举报

26

主题

1

好友

2082

积分

白金长老

Rank: 10

14#
发表于 2009-3-1 06:57 PM |只看该作者
怎么你好像才开始啊lol~
我帮不了你~因为我看得出来你的assignment题目是包含一些我还没有拿的课


回复

使用道具 举报

11

主题

0

好友

1584

积分

白银长老

Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9

15#
发表于 2009-3-1 08:04 PM |只看该作者

回复 #14 丧送狂曲 的帖子

对啊,因为我不会做。
明天就要交了 ==‘


回复

使用道具 举报

26

主题

1

好友

2082

积分

白金长老

Rank: 10

16#
发表于 2009-3-1 09:42 PM |只看该作者

回复 #15 Cougar 的帖子

我的assignment也是很多自己explore的~没找看吗


回复

使用道具 举报

11

主题

0

好友

1584

积分

白银长老

Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9

17#
发表于 2009-3-2 08:24 AM |只看该作者
原帖由 丧送狂曲 于 2009-3-1 09:42 PM 发表
我的assignment也是很多自己explore的~没找看吗

都看不懂,连基本都不会。
很讨厌C++
不知道要学Programming 到什么时候!!


回复

使用道具 举报

26

主题

1

好友

2082

积分

白金长老

Rank: 10

18#
发表于 2009-3-2 11:53 AM |只看该作者
你读什么课程?em0010


回复

使用道具 举报

11

主题

0

好友

1584

积分

白银长老

Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9

19#
发表于 2009-3-3 09:38 PM |只看该作者
原帖由 丧送狂曲 于 2009-3-2 11:53 AM 发表
你读什么课程?em0010

Computer Science
烦恼,应该去读Management。
我会活得快乐点


回复

使用道具 举报

26

主题

1

好友

2082

积分

白金长老

Rank: 10

20#
发表于 2009-3-3 10:32 PM |只看该作者
不喜欢还拿这个科目...不明白...


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2024-11-30 01:32 PM , Processed in 0.095742 second(s), 21 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部