phfb.net
当前位置:首页 >> 用Do whilE写1到10的乘积 >>

用Do whilE写1到10的乘积

#include<stdio.h> int main(void) { long result=1; int i=1; while(i<=10) { result*=i; i++; } printf("10的阶乘是:%ld\n",result); return 0; }

int i=1,n=1; while(i<=10){ n*=i; i++; }

do 的: Private Sub Form_click()Dim x As IntegerDim sum As Integerx = 0sum = 0Do Until x > 10sum = sum + xx = x + 1LoopPrint sumEnd Sub while的 Private Sub Form_click()Dim x As IntegerDim sum As Integerx = 0sum = 0While x <= 10sum = sum + xx = x + 1WendPrint sumEnd Sub

Private Sub Form_Click()Dim a(10),b(10),c,d,i,j,Num As Integerc = 0d = 0RandomizeFor i = 1 To 10Num = Int(Rnd * 10 + 1)If Num Mod 2 = 0 Thenc = c + 1a(c) = Num '定义偶数数组Elsed = d + 1b(d) = Num '定义奇数数组End IfPrint Num;Next iPrinti

create or replace procedure additive(min_value number, max_value number,add_value out number) is i number:=min_value;begin add_value := 0; while i 评论0 0 0

#include<stdio.h> void main() { int i=1,n=1; while(i<=100) { n=n*i; i++;/*实现i的循环*/ } printf("100!de zhi shi:%10e",n);/*用指数形式表示出*/ } #include "stdio.h" #define TEST_NUM 100 int main(int argc, char **argv) { int nLoop = 2;

int score=1; do { system.out.println(score+"的平方是:"+score*score); score++; } while(score<=10);

#includevoid main(){ long n=50; long s=1; while(n>0) { s*=n; n--; } printf("Result is %d\n",s);}#includevoid main(){ long n=50; long s=1; do { s*=n; n--; }while(n>0); printf("Result is %d\n",s);}乘积太大了,都越界了

using System; namespace Factorial { class Program { //求1到num的阶乘之和 static long SumFactorial(byte num) { byte i = 1; long sum = 0; do { long factorial = 1; byte j = 1; while (j { factorial *= j++; } sum += factorial; i++; } while (i return sum; } //测试

回答了,别重复提问了dim i%,jx#i=1jx=1do while i 评论0 0 3

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