要求用VB,或者C語言,編寫程式,從鍵盤輸入奇數n

2021-03-04 09:01:45 字數 2718 閱讀 6700

1樓:匿名使用者

#include

main()

printf("sum=%d",sum);}}

2樓:匿名使用者

||#include

int main(void)

return 0;}

3樓:匿名使用者

#include

void main()

printf("%d\n", j);}

求vb程式設計,兩個按鈕"奇數和","偶數和"。輸入整數n,計算1~n之間的奇數和,偶數和,並顯示 30

4樓:匿名使用者

private sub ***mand1_click()dim n as integer

dim s as double

s = 0

n = val(text1.text)

for i = 1 to n

if i mod 2 = 1 then s = s + inext i

text3.text = s

end sub

private sub ***mand2_click()dim n as integer

dim s as double

s = 0

n = val(text1.text)

for i = 1 to n

if i mod 2 = 0 then s = s + inext i

text2.text = s

end sub

c語言程式設計實現從鍵盤輸入n個整數 分別求出奇數和偶數的和 **等 60

5樓:匿名使用者

要考慮到0是乙個非正非負的特殊偶數

#include

void main()

printf("奇數之和為:%d,偶數之和為:%d\n",sum1,sum2);}

6樓:孟羽然

#include

int main() else if (num % 2 == 0) else

}printf("sum of odd numbers is: %d\n", sum_odd);

printf("sum of event numbers is: %d\n", sum_even);

return 0;}

7樓:匿名使用者

#include "stdio.h"

int main()

printf("奇數和為:%d,偶數

版和為:%d,共%d個數權。\n",js,os,n);}

vb作業題,編寫程式,求s=1*2*3*...*n的值。其中n值從鍵盤上輸入,在窗體上輸出s值。

8樓:聽不清啊

private sub ***mand1_click()n = cint(inputbox("求

bain!,

du請輸zhi

入daon的值:

版"))

s = 1

for i = 2 to n

s = s * i

next i

msgbox ("n!權=" & s)

end sub

9樓:匿名使用者

private sub form_click()dim a as integer, i as integer, s as long

s = 1

a = inputbox("請輸

來入自乙個

數", "提示", "5")

for i = 1 to a

s = s * i

if i = a then

print str(i) + "=" + str(s)else

print str(i) + "*";

end if

next

end sub

利用vb程式設計乙個程式求1+3+5+......n的和

10樓:匿名使用者

private sub form_click()dim a as integer, i as integer, sum as integer

a = inputbox("輸入乙個大於1的奇數")for i = 1 to a

if i mod 2 = 1 then

sum = sum + i

print i;

end if

next

print

print "和:" + cstr(sum)end sub

11樓:匿名使用者

dim sum as long

for i=1 to n

sum=sum+i

next i

print sum

12樓:匿名使用者

private sub ***mand1_click()dim n as single, s as single, i as single

n = 22

for i = 1 to n step 2s = s + i

next

print s

end sub

s是1~n所有奇數相加的值

用c語言編寫程式,得出1 ,用C語言編寫程式,得出1 1 2 1 3 1 100的值

include int main void printf num d n num return 0 include int main 這樣是不更簡潔呢?物聯網校企聯盟技術部 void main include void main main printf d sum main 不懂再問,給分哦,親。i...

用C語言編寫程式,要求使用者自己設計迷宮,從出口出發

include include include include include define x1 a 120 20 define y1 b 40 20 define up 72 define down 80 define left 75 define right 77 define enter 1...

用C語言編寫程式,用C語言編寫三個程式

第一題 include include include include void fun char str,char c intmain void fun char str,char c 第三題 include include define n 4 typedef structshu intmain...