--- tags: DICE C --- 15-1 印到我說停 === > [name=CHAWTeam] --- 目錄:[DICE C語言程式破解](https://hackmd.io/@CHAWTeam/DiceC) --- 題目 -- ```! 寫一個程式,印出「HaHaHa!」, 不管我說什麼都持續印「HaHaHa!」, 直到我說「-1」,才停止。 輸入範例: 2 3 4 5 -1 輸出範例: HaHaHa! HaHaHa! HaHaHa! HaHaHa! C範例程式: #include <stdio.h> int main(){ int x=0; scanf("%d",&x); while(........){ printf("HaHaHa!\n"); scanf("%d",&x); } return 0; } C++範例程式 #include <iostream> int main() { int x=0; std::cin>>x; while(x!=-1){ std::cout<<"HaHaHa!\n"; std::cin>>x; } return 0; } ``` 程式碼 -- ```c= #include <stdio.h> int main() { int x = 0; scanf("%d", &x); while(x != -1) { printf("HaHaHa!\n"); scanf("%d", &x); } return 0; } ``` 執行 --- ```! 2 HaHaHa! 3 HaHaHa! 4 HaHaHa! 5 HaHaHa! -1 ``` --- [查看我們在HackMD上的所有筆記](https://hackmd.io/@CHAWTeam) 目錄:[DICE C語言程式破解](https://hackmd.io/@CHAWTeam/DiceC) --- {%hackmd Iiu5mOixR7yWkPHKCkabBg %} <iframe class="LikeCoin" height="235" src="https://button.like.co/in/embed/chawteam/button?referrer=https://hackmd.io/@CHAWTeam/DiceC-15-1" width="100%"></iframe> --- {%hackmd i1nMRrZcTFmTvoF897K9zg %}