Last active
May 20, 2016 17:08
-
-
Save cocodrips/3dc2bdc7b39e5e3987998f25fa1d5abe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int q1() { | |
int array[3][3]; | |
for (int i = 0; i < 3; i++){ | |
for (int j = 0; j < 3; j++) { | |
array[i][j] = i * 3 + j; | |
cout << array[i][j] << " "; | |
} | |
cout << endl; | |
} | |
// Question 1 | |
cout << array[5] << endl; | |
// 1. コンパイルエラー | |
// 2. どこかのアドレスっぽいやつ (正しい言い方ある?) | |
// 3. 5 | |
// 答え:2 こういうやつとか-> 0x7fff53b51aac | |
// 5を出すには? | |
cout << ((int*)array)[5] << endl; | |
} | |
int main() { | |
cout << "Question 1" << endl; | |
q1(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment