Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void exampleOne();
- void exampleTwo();
- void exampleThree();
- int main()
- {
- //exampleOne(); // One-D Array
- //exampleTwo(); // Two-D Array
- exampleThree(); // Example-Usage
- return 0;
- }
- void exampleOne()
- {
- //index --> 0 1 2
- string user_name[]{"@hmad Mispun", "Zakiman Maznun", "Luqman Hakim"};
- //1 - Example printing array
- cout << "array at index 0 - " << user_name[0] << endl;
- cout << "array at index 1 - " << user_name[1] << endl;
- cout << "array at index 2 - " << user_name[2] << endl << endl;
- //2 - Example Access and change value inside an array
- user_name[0] = "Ahmad Mispun";
- //3 - Output after change
- cout << "array at index 0 - " << user_name[0] << endl;
- cout << "array at index 1 - " << user_name[1] << endl;
- cout << "array at index 2 - " << user_name[2] << endl << endl;
- }
- void exampleTwo()
- {
- int user_rating[3][4]
- {
- 0 , 4 , 2 , 3 ,
- 3 , 1 , 2 , 3 ,
- 0 , 1 , 5 , 3
- };
- //1 - Example printing array
- cout << "array at index [0][0] - " << user_rating[0][0] << endl;
- cout << "array at index [1][0] - " << user_rating[1][0] << endl;
- cout << "array at index [2][0] - " << user_rating[2][0] << endl << endl;
- //2 - Example Access and change value inside an array
- user_rating[0][0] = 1;
- //3 - Output after change
- cout << "array at index [0][0] - " << user_rating[0][0] << endl;
- cout << "array at index [1][0] - " << user_rating[1][0] << endl;
- cout << "array at index [2][0] - " << user_rating[2][0] << endl << endl;
- }
- void exampleThree()
- {
- string user_name[]{ "Ahmad Mispun", "Zakiman Maznun", "Luqman Hakim" };
- string movie_name[]{ "Big Daddy", "Green Mile", "Lake Placid", "Blue Streak" };
- int user_rating[3][4]
- {
- 0 , 4 , 3 , 5 ,
- 2 , 3 , 3 , 3 ,
- 1 , 4 , 5 , 3
- };
- while (true)
- {
- for (size_t i = 0; i < 3; i++)
- {
- cout << "|-" << i << "-|" << user_name[i];
- }
- cout << endl;
- for (size_t i = 0; i < 4; i++)
- {
- cout << "|-" << i << "-|" << movie_name[i];
- }
- cout << endl << endl;
- int user_input{ 0 };
- cout << "Enter user name :";
- cin >> user_input;
- int movie_input{ 0 };
- cout << "Enter movie name :";
- cin >> movie_input;
- cout << "User -> " << user_name[user_input];
- cout << "| Rate Movie --> " << movie_name[movie_input];
- cout << "| " << user_rating[user_input][movie_input] << "-STAR"<< endl << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement