I am quite fond with the game Castle Age in Facebook. From time to time, I google about it to learn a bit more. Then I found these formula of BSI and LSI. Lazy to use a calculator, I use a computer instead. :) I have an executable if you want. :P
[Edit:] Oh, somehow old link is gone? Well, it is quite outdated though. New link
Tuesday, November 30, 2010
Saturday, November 27, 2010
1. Define an enumeration type named SHAPE containing values including sphere, rectangle, square, triangle and polygon.
2. Define an enumeration type OPTION which contains first, second and third.
3. Use OPTION and SHAPE as row and column respectively and print the values in a matrix format for an array MATRIX
2. Define an enumeration type OPTION which contains first, second and third.
3. Use OPTION and SHAPE as row and column respectively and print the values in a matrix format for an array MATRIX
#include <iostream>using namespace std; int main() { /*Define an enumeration type named SHAPE containing values including sphere, rectangle, square, triangle and polygon.*/ enum SHAPE {sphere,rectangle,square,triangle,polygon}; //Define an enumeration type OPTION which contains first, second and third. enum OPTION {first,second,third}; /*Use OPTION and SHAPE as row and column respectively and print the values in a matrix format for an array MATRIX*/ int MATRIX[OPTION][SHAPE]; //incomplete cin.get(); return 0; }
Sunday, November 14, 2010
Exploring internet: Some of the things I found
I am taking a little break from trying to solve Euler's Problem. It seems if I learn Java, it will be easier. C++ has limit to the largest int it can use. Beside, I think it might be easier. So I surf around instead. :)
A computer science student should learn more than programming.
I like photoshopping, but I am limited to simple forum avatar and signature. Usually I take anime or game render. Luckily, I found a site that quite nice without any annoying requirement. ;)
I was wondering, if Mozilla Firefox have add-ons, what Google Chrome have? Extension.
Next semester, I am going to learn programming II(focus on Java, yay new language), Multimedia(yay my photoshop skill will come in handy), economy(oh my God), calculus II(oh, another math), English Preparation for Muet(need to read -.- ) and CTU(learning the way of life on paper).
A computer science student should learn more than programming.
I like photoshopping, but I am limited to simple forum avatar and signature. Usually I take anime or game render. Luckily, I found a site that quite nice without any annoying requirement. ;)
I was wondering, if Mozilla Firefox have add-ons, what Google Chrome have? Extension.
Next semester, I am going to learn programming II(focus on Java, yay new language), Multimedia(yay my photoshop skill will come in handy), economy(oh my God), calculus II(oh, another math), English Preparation for Muet(need to read -.- ) and CTU(learning the way of life on paper).
Sunday, November 7, 2010
Saturday, November 6, 2010
Quiz 2
Question:
Every student's record must consist of Age, ID Number and Mark.
a) Declare a struct named PELAJAR which consists of the above component.
b) In the main function, declare a student array which consists of 20 students.
c) Create a function to read in the data for 20 students by using the student array and maximum number of students as parameters.
d) Create a function to display the data for all students by using the student array and maximum number of students as parameters.
e) Create a function to find a student with the highest mark.
f) Complete the program by creating the main function:
(i) Initialize the student array to dummy values.
(ii) Create appropriate function calls to call functions in c), d) and e).
My answer:
#include <iostream>
#include <string>
using namespace std;
const int size = 20; int i;
struct PELAJAR
{
int Age;
string ID_Number;
float Mark;
}students[size];
void read(PELAJAR students[size],int size)
{
for (i=0;i<size;i++)
{
cout << (i+1) << ": " << endl;
cout << "\tAge: ";
cin >> students[i].Age;
cout << "\tID Number: ";
cin >> students[i].ID_Number;
cout << "\tMark: ";
cin >> students[i].Mark;
cout <<endl;
}//for
}//Read
void display(PELAJAR students[size],int size)
{
cout << endl;
cout << "No\tAge\tID Number\tMark" << endl;
for (i=0;i<size;i++)
{
cout << (i+1) << "\t" << students[i].Age << "\t" << students[i].ID_Number
<< "\t" << students[i].Mark << endl;
}
}//display
void highest (void)
{
float highest = students[0].Mark;
int high=0;
for (i=1;i<size;i++)
{
if (students[i].Mark>highest)
{
highest=students[i].Mark;
high=i;
}
}
cout << endl;
cout << "Student with highest mark is student " << (high+1)
<< " ID Number: " << students[high].ID_Number
<< " with Mark: " << students[high].Mark;
cout << endl;
}
int main()
{
for (i=0;i<size;i++)
{
students[i].Age=0;
students[i].ID_Number="0";
students[i].Mark=0.0;
}
read(students,size);
display (students,size);
highest();
cin.ignore();
cin.get();
return 0;
}
Every student's record must consist of Age, ID Number and Mark.
a) Declare a struct named PELAJAR which consists of the above component.
b) In the main function, declare a student array which consists of 20 students.
c) Create a function to read in the data for 20 students by using the student array and maximum number of students as parameters.
d) Create a function to display the data for all students by using the student array and maximum number of students as parameters.
e) Create a function to find a student with the highest mark.
f) Complete the program by creating the main function:
(i) Initialize the student array to dummy values.
(ii) Create appropriate function calls to call functions in c), d) and e).
My answer:
#include <iostream>
#include <string>
using namespace std;
const int size = 20; int i;
struct PELAJAR
{
int Age;
string ID_Number;
float Mark;
}students[size];
void read(PELAJAR students[size],int size)
{
for (i=0;i<size;i++)
{
cout << (i+1) << ": " << endl;
cout << "\tAge: ";
cin >> students[i].Age;
cout << "\tID Number: ";
cin >> students[i].ID_Number;
cout << "\tMark: ";
cin >> students[i].Mark;
cout <<endl;
}//for
}//Read
void display(PELAJAR students[size],int size)
{
cout << endl;
cout << "No\tAge\tID Number\tMark" << endl;
for (i=0;i<size;i++)
{
cout << (i+1) << "\t" << students[i].Age << "\t" << students[i].ID_Number
<< "\t" << students[i].Mark << endl;
}
}//display
void highest (void)
{
float highest = students[0].Mark;
int high=0;
for (i=1;i<size;i++)
{
if (students[i].Mark>highest)
{
highest=students[i].Mark;
high=i;
}
}
cout << endl;
cout << "Student with highest mark is student " << (high+1)
<< " ID Number: " << students[high].ID_Number
<< " with Mark: " << students[high].Mark;
cout << endl;
}
int main()
{
for (i=0;i<size;i++)
{
students[i].Age=0;
students[i].ID_Number="0";
students[i].Mark=0.0;
}
read(students,size);
display (students,size);
highest();
cin.ignore();
cin.get();
return 0;
}
Subscribe to:
Posts (Atom)