--- tags: DICE C --- 3-1 指定整數 === > [name=CHAWTeam] [time=Feb 15, 2022] --- 目錄:[DICE C語言程式破解](https://hackmd.io/@CHAWTeam/DiceC) 上一篇:[2_2 身高體重](https://hackmd.io/@CHAWTeam/DiceC-2_2) 下一篇:[3-2 加上一些形容詞](https://hackmd.io/@CHAWTeam/DiceC-3-2) --- 題目 --- ```! 寫一個程式,在記憶體放置一個整數3,然後印出來。 輸出範例: 3 C範例程式: #include<stdio.h> int main() { int num; num=3; printf("......\n",......); return 0; } C++範例程式: #include<iostream> using namespace std; int main() { int num; num=3; cout<<num<<endl; return 0; } ``` 程式碼 --- ```c= #include <stdio.h> int main() { int num; //定義「num」變數 num = 3; //定義 num 為 3,並放入記憶體 printf("%d", num); //「%d」為整數格式指定字,指定輸出 num return 0; } ``` :::info **指派運算 Assignment** > [指派運算子會將值儲存在左運算元所指定的物件中。](https://docs.microsoft.com/zh-tw/cpp/cpp/assignment-operators?view=msvc-170) > [name=Microsoft Docs][color=#290f91] `=`就是最基礎的指派運算子。 ::: :::success 輸入或輸出後的括號內,一樣要記得加上`""`,系統才會知道要印出指定字串。 ::: 輸出 --- ```! 3 ``` --- [查看我們在HackMD上的所有筆記](https://hackmd.io/@CHAWTeam) 目錄:[DICE C語言程式破解](https://hackmd.io/@CHAWTeam/DiceC) 上一篇:[2_2 身高體重](https://hackmd.io/@CHAWTeam/DiceC-2_2) 下一篇:[3-2 加上一些形容詞](https://hackmd.io/@CHAWTeam/DiceC-3-2) --- {%hackmd Iiu5mOixR7yWkPHKCkabBg %} <iframe class="LikeCoin" height="235" src="https://button.like.co/in/embed/chawteam/button?referrer=https://hackmd.io/@CHAWTeam/DiceC-3-1" width="100%"></iframe> --- {%hackmd i1nMRrZcTFmTvoF897K9zg %}
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up