Last active
December 17, 2015 18:59
-
-
Save catupper/5657519 to your computer and use it in GitHub Desktop.
GCCの理解度チェーック main関数で呼び出してる各関数の返り値を予想してから、 実際にコンパイルして解答を確認してみてね!
This file contains 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<stdio.h> | |
int q1(); | |
int q2(); | |
int q3(); | |
int q4(); | |
int q5(); | |
int q6(); | |
int q7(); | |
char* q8(); | |
int q9(); | |
int q10(); | |
int main(){ | |
printf("%d\n", q1()); | |
printf("%d\n", q2()); | |
printf("%d\n", q3()); | |
printf("%d\n", q4()); | |
printf("%d\n", q5()); | |
printf("%d\n", q6()); | |
printf("%d\n", q7()); | |
printf("%s\n", q8()); | |
printf("%d\n", q9()); | |
printf("%d\n", q10()); | |
} | |
//Q.1 | |
int q1(){ | |
int k = 10; | |
int p = 0; | |
while(k--){ | |
p += k; | |
} | |
return p; | |
} | |
//Q.2 | |
int q2(){ | |
int a = 2; | |
if(4 < a, a < 6){ | |
return a; | |
} | |
else{ | |
return -a; | |
} | |
} | |
//Q.3 | |
int q3(){ | |
int a = 3; | |
switch(a){ | |
case 3: | |
a += 1; | |
case 4: | |
a += 2; | |
case 5: | |
a += 3; | |
} | |
return a; | |
} | |
//Q.4 | |
int q4(){ | |
int a = 1, b = 1; | |
b-- && --b || a++; | |
return a; | |
} | |
//Q5 | |
int q5(){ | |
int i, j, r = 0, n = 3; | |
for(i = 0;i < n;i++) | |
r++; | |
for(j = 0;j < n;j++) | |
r++; | |
return r; | |
} | |
//Q6 | |
typedef struct tmp{ | |
int a, b; | |
} S; | |
int q6(){ | |
S *a, *b; | |
S as[100], bs[100]; | |
a = &as[55]; | |
b = &bs[52]; | |
a->b = 0; | |
b->a = 1; | |
b = a - 10; | |
return a --> b; | |
} | |
//Q7 | |
int q7(){ | |
int a = 2, b = -3; | |
return b%a + a%b; | |
} | |
//Q8 | |
char* q8(){ | |
return "False"":?"?:"eslaF"; | |
} | |
//Q.9 | |
int q9(){ | |
int a = 3, b = 5, c = 8; | |
a /= 3; | |
a *= 3; | |
b /*= 3; | |
c */= 3; | |
return b; | |
} | |
//Q.10 | |
#define comb(x, y) (x##y) | |
int q10(){ | |
int q10num = 3; | |
int num = 4; | |
q10num *= num; | |
return comb(q10, num); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment