bshy.net
当前位置:首页>>关于利用do-while语句计算1~n中的奇数的资料>>

利用do-while语句计算1~n中的奇数

1方法(1)使用一个计数器来判断终止条件(2)用除以2后的余数来判断奇偶2代码#includeintmain(){intcount,sumEven,sumOdd;count=sumEven=sumOdd=0;while(++count

1 方法 (1)使用一个计数器来判断终止条件 (2)用除以2后的余数来判断奇偶 2 代码 #include int main() { int count, sumEven, sumOdd; count = sumEven = sumOdd = 0; while (++count

int sum = 0; int i = 0; while (i

Dim Sj As Integer Dim So As Integer Dim i As Integer Sj = 0 So = 0 i = 1 Do While i

#include//do while int main() { int i=0,sum=0; do { if(i%2!=0) { sum=sum+i; } i++; }while(i

#include//for int main() { int i,sum=0; for(i=0;i

int i=1 int sum=0 do{ sum+=i i++ }while(i

c语言: int fx() { int i, a; i = 1; a = 0; do { a += i; i += 2; } while(i < 100) return a; } vb6(vba): public function fx() as long dim i as long, a as long a = 0; i = 1; do a =a + i i = i + 2 loop while i < 100 fx = a; end ...

#include "stdio.h" void main() { int i,sum=0; for(i=1;i

网站首页 | 网站地图
All rights reserved Powered by www.bshy.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com