Posts

Showing posts from 2014

Reflection: Assignment 2

Image
Đề bài:  Phát triển bài Assignment 1 theo yêu cầu sau: Xây dựng cấu trúc dữ liệu struct để lưu thông tin khách hàng và khoản vay đối với ngân hàng gồm các thông tin: - Số hợp đồng - Họ tên khách hàng - Tổng số tiền vay - Thời hạn (Số tháng) - Lãi suất - Có tham gia bảo hiểm tín dụng không? Nếu có thì mức nào? - Có là gia đình có công không? - Làm việc trong lực lượng vũ trang? Sử dụng array để lưu trữ danh sách thông tin khách hàng và khoản vay đối với ngân hàng Xây dựng menu chương trình gồm các chức năng quản lý như sau: 1. Nhập danh sách các hợp đồng vay hoặc nạp dữ liệu từ file 2. Hiển thị danh sách các hợp đồng vay 3. Thêm vào cuối một hợp đồng vay 4. Tìm kiếm một khoản vay theo số hợp đồng: 5. Tìm kiếm hợp đồng vay theo tên hoặc họ tên khách hàng 6. Tìm kiếm hợp đồng vay theo tổng số tiền vay 7. Sửa thông tin một hợp đồng nào đó tìm được 8. Thống kê - Tổng số hợp đồng, tổng số tiền đã cho vay - Danh sách các khoản vay của từng khách hàng - Tổng dư nợ ...

Reflection: ArrayReview

Image
I, Summary Array types in C are traditionally of a fixed, static size specified at compile time.            dataType arrayIdentifier[ size ] = { value, ... , value }; The syntax of a function call that passes an array is             functionIdentifier ( arrayIdentifier, ... ) The syntax of a function header that receives an array address is           dataType functionIdentifier ( dataType arrayIdentifier [ ], ... ) II, Applied to solve problems I. Re-code again the example in the clip This is my result:  link code: II. Implement functions 1. Nhập vào kích thước và các phần tử của một mảng một chiều void nhap(int *n, int mang[]) 2. Copy một mảng sang một mảng khác void  copy(int nguon[], int dich[], int n) 3. tìm kiếm k trong mảng, không có trả về -1, có trả về chi so đầu tiên int tim(int mang[], int n, int k) 4. In danh sách vị trí của các phần tử...

Reflection: ArrayAsParam

Image
I, Summary Arguments  The syntax of a function call that passes an array is             functionIdentifier ( arrayIdentifier, ... ) Where functionIdentifier is the name of the function and arrayIdentifier is the array name without brackets. Parameters The syntax of a function header that receives an array address is           dataType functionIdentifier ( dataType arrayIdentifier [ ], ... ) The brackets following arrayIdentifier inform the compiler that the parameter holds the address of a one-dimensional array. - Arrays are automatically passed by reference. Do not use &. - If the function modifies the array, it is also modified in the calling environment II, Applied to solve problems I. Re-code again the example in the clip This is my code This is my result inputArray.cpp II. Implement functions to solve problems in reflection array (as in clip array review) arrayRev...

Reflection: Assignment1_bank

Image
Đề bài: Viết chương trình tính tiền khách hàng phải trả vào gốc và lãi cho ngân hàng theo nghiệp vụ được mô tả như sau: Với mỗi khoản vay của ngân hàng. Khách hàng đều phải cam kết trả nợ trong một khoảng thời gian nhất định tính bằng tháng. Theo khoảng thời gian này, hàng tháng khách hàng phải trả khoản gốc cho khoản vay bằng Tổng dư nợ : số tháng. Ví dụ khách hàng vay 1,2 tỷ trong vòng 5 năm (60 tháng) thì mỗi tháng khách hàng phải trả gốc là 1,2 tỷ : 60 tháng = 20 triệu/tháng Khoản tiền lãi sẽ được tính theo dư nợ hiện thời với lãi suất theo hợp đồng tín dụng. Ví dụ khách hàng vay 1.2 tỷ với lãi suất 12%/năm. Sau 10 tháng trả nợ, dư nợ của khách hàng còn 1 tỷ. Vậy khoản lãi của khách hàng cho tháng 11 sẽ là: 1 tỷ * 12/100/12 = 10 triệu Với mỗi khoản vay, hàng tháng khách hàng bắt buộc phải trả một khoản bảo hiểm cho tài sản thuế chấp bằng 1.2% /năm cho tổng số tiền vay. Ví dụ với khoản vay 1,2 tỷ. Hàng tháng khách hàng phải trả tiền bảo hiểm tài sản là: 1.2 tỷ * 1.2/100/12...

Reflection: Array

Image
I, Summary A data structure is a collection of data types designed to store information in some optimal way. The simplest example of a data structure is an array. The fundamental unit of an array is an element. Each element holds has an index and holds one data value.  Index numbering starts at 0 and extends to one less than the size of the array. To refer to an element, we use the array name followed by bracket notation around the element index.  dataType arrayIdentifier[ size ] = { value, ... , value }; II, Applied to solve problems A,Write program 1. Declare an double array with max 100 elements 2. Input an positive integer n that indicated the number of element of array 3. Input n elements of array 4. Display array has just been inputted 5. Calculate sum of all elements, sum of odd element, average of even elements, average of element at odd index Source and demo: file source:  array.cpp B, Pro...

Reflection: Pointer

Image
I, Summary What is pointer? Pointers are the container/variable who holds address of other variables. C uses pointers in three different ways:      - C uses pointers to create dynamic data structures -- data structures built up from blocks of memory allocated from the heap at run-time.      - C uses pointers to handle variable parameters passed to functions.      - Pointers in C provide an alternative way to access information stored in arrays. Pointer techniques are especially valuable when you work with strings. There is an intimate link between arrays and pointers in C. The declaration of pointers follows this format: type * name;  II, Applied to solve problems 1. void input(int*n, int*m); – input and check n>0, m>0 2. int fun2(int n, int m); Function returns n! + m n if n > 0 and m > 0, otherwise return 0 3. double fun6(int n); Function returns value calculated by formula 4. i...

Reflection: Scope Variables

Image
I, Summary There are two types of c variables.      - Local      - Global Local variables:  Variable whose existence is known only to the main program or functions are called local variables. Local variables are declared with in the main program or a function. Global variables:  Variables whose existence is known to the both main() as well as other functions are called global variables. Global variables are declared outside the main() and other functions. Difference between Local and Global c variables:      - Local c variable is declared in functions and blocks, while global c variables are declared outside functions and blocks.      - Local c variables can be accessed only that function and blocks which declared it, while global c variables can be accessed within all program.      - Local c variables when declared not initialized automatically by system you have to decla...