1樓:匿名使用者
1、使用mod判斷餘數,如果為1則為奇數,否則為偶數2、**示例如下回:
procedure tform1.btn1click(sender: tobject);
varnb : integer;
begin
nb := strtoint(edt1.text);
if (nb mod 2 = 1) thenbegin
showmessage('是奇
答數!');
endelse
begin
showmessage('是偶數!');
end;
end;
3、效果如下:
2樓:veket的小號
簡單寫點吧
procedure tform1.button1click(sender: tobject);
vara:integer;
begin
if trystrtoint(edit1.text, a) thenbegin
if a mod 2 >0 then
label1.caption := '這是個奇數'
else
label1.caption := '這是個偶數';
endelse
showmessage('請輸入整數,不要輸入字母專、標點、小數屬... !');
end;
c語言程式設計如何判斷輸入整數的正負性和奇偶性?
3樓:樂觀的徐強
void main()
else
num=num%2;
if(num==0)
else
#include
main()
右邊的是註釋!
4樓:昂寶西門穎初
#include
main()
右邊dao的是註釋!
設計一個程式:輸入一個整數,判斷它的奇偶性。
5樓:匿名使用者
main()
else
getch();}
c語言:編寫一個程式,判斷一個整數的奇偶性。如果是奇數,輸入1,是偶數,輸入2.
6樓:
#include
int odd_even(int n)
int main()
7樓:匿名使用者
#include
void main()
請參考上面內
的**。容
8樓:求知者不老
#include
void main()
設計一個程式:輸入一個整數,判斷它的奇偶性。
9樓:青龍vs朱雀
void main()
10樓:大唐一世
這個,你買本c語言書就可以解決,10年前可以幫你,現在我老了
計算機編寫程式 輸入一個整數,並判斷其奇偶性。
11樓:匿名使用者
#include
int main()
用指標編寫程式,用指標編寫一個程式
include include include define max 100 輸入的最大字元數為100 int main printf character total number is d n total printf upper character number is d n count upp...
用c語言編寫程式從鍵盤上輸入字串輸
include include define longth 10 定義字串最大長度void main 我以前寫的,可以執行,希望有幫助 1.int strcmp const char str1,const char str2 功能 比較字串str1 and str2,返回值如下 返回值 0 str1...
大一c語言編寫程式,輸入日期年月日,計算並輸出該日是該年
x f 不太確定你出現了什麼錯誤。編寫一個c語言程式,輸入一個年月日,輸出這個日期是這一年的第幾天。考慮閏年 include void main break case 4 case 6 case 9 case 11 if day 0 day 30 break case 2 2月閏年可以輸入29日 e...