Re: [問題] 九九乘法表不用迴圈是叫我直接從1列到81?

看板C_and_CPP (C/C++)作者 (Cindy Wang)時間6年前 (2018/07/18 03:16), 編輯推噓4(405)
留言9則, 6人參與, 6年前最新討論串9/29 (看更多)
※ 引述《red0whale (red whale)》之銘言: : 剛才做題目, : https://i.imgur.com/NI4TYj5.jpg
: 九九乘法表用兩個或一個迴圈來做我都會 : 但不用迴圈叫我列九九乘法表是哪招? : 難道是要我直接從1*1列到9*9嗎? : 還是其實有妙招? : 說實在我真想不到不用迴圈就能簡單列出九九乘法表的方法了 這一個版本.. 我只能確定 it works on my machine....XD (x86_64) 99.c: #include <stdio.h> long long salon(long long hair, int i){ if( i < 1 ) hair = 2[&hair]; if( i < 81 ) 2[&hair] = hair; return hair; } int main(){ int i = -1; long long hair = salon(hair, ++i); printf("%d x %d = %2d %c", i/9+1, i%9+1, (i/9+1) * (i%9+1), 32-22*!(i%9-8)); hair = salon(hair, ++i); return 0; } $ gcc -O0 -o 99 99.c $ ./99 1 x 1 = 1 1 x 2 = 2 1 x 3 = 3 1 x 4 = 4 1 x 5 = 5 1 x 6 = 6 1 x 7 = 7 1 x 8 = 8 1 x 9 = 9 2 x 1 = 2 2 x 2 = 4 2 x 3 = 6 2 x 4 = 8 2 x 5 = 10 2 x 6 = 12 2 x 7 = 14 2 x 8 = 16 2 x 9 = 18 3 x 1 = 3 3 x 2 = 6 3 x 3 = 9 3 x 4 = 12 3 x 5 = 15 3 x 6 = 18 3 x 7 = 21 3 x 8 = 24 3 x 9 = 27 4 x 1 = 4 4 x 2 = 8 4 x 3 = 12 4 x 4 = 16 4 x 5 = 20 4 x 6 = 24 4 x 7 = 28 4 x 8 = 32 4 x 9 = 36 5 x 1 = 5 5 x 2 = 10 5 x 3 = 15 5 x 4 = 20 5 x 5 = 25 5 x 6 = 30 5 x 7 = 35 5 x 8 = 40 5 x 9 = 45 6 x 1 = 6 6 x 2 = 12 6 x 3 = 18 6 x 4 = 24 6 x 5 = 30 6 x 6 = 36 6 x 7 = 42 6 x 8 = 48 6 x 9 = 54 7 x 1 = 7 7 x 2 = 14 7 x 3 = 21 7 x 4 = 28 7 x 5 = 35 7 x 6 = 42 7 x 7 = 49 7 x 8 = 56 7 x 9 = 63 8 x 1 = 8 8 x 2 = 16 8 x 3 = 24 8 x 4 = 32 8 x 5 = 40 8 x 6 = 48 8 x 7 = 56 8 x 8 = 64 8 x 9 = 72 9 x 1 = 9 9 x 2 = 18 9 x 3 = 27 9 x 4 = 36 9 x 5 = 45 9 x 6 = 54 9 x 7 = 63 9 x 8 = 72 9 x 9 = 81 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 112.121.78.5 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1531855007.A.FCC.html

07/18 05:47, 6年前 , 1F
去動 stack XDDDD 可以,本串最ㄎㄧㄤ,你磕什麼我也要
07/18 05:47, 1F

07/18 06:09, 6年前 , 2F
偷改ret壞壞
07/18 06:09, 2F

07/18 10:42, 6年前 , 3F
我什麼時候按到syntax on了
07/18 10:42, 3F

07/18 11:04, 6年前 , 4F
等等該不會冒出shellcode那種直接跑的啊
07/18 11:04, 4F

07/18 11:07, 6年前 , 5F
shellcode那個很吃執行環境
07/18 11:07, 5F

07/18 11:08, 6年前 , 6F
先把NX關掉才能玩shellcode 不然就要用ROP
07/18 11:08, 6F

07/18 17:13, 6年前 , 7F
vidal sassoon
07/18 17:13, 7F

07/18 17:16, 6年前 , 8F
精神接近IOCCC了 建請版主定本次為第一屆POCCC
07/18 17:16, 8F

07/18 17:16, 6年前 , 9F
(PTT Obfuscated C Code Contest)
07/18 17:16, 9F
文章代碼(AID): #1RJa2V_C (C_and_CPP)
討論串 (同標題文章)
文章代碼(AID): #1RJa2V_C (C_and_CPP)