精华内容
下载资源
问答
  • 用C语言的while循环,打印九九乘法
    千次阅读
    2021-05-19 20:06:17

    用C语言的while循环,打印九九乘法表

    用C语言的while循环:

    #include

    int main(void)

    {

    int row = 1;

    while (row <= 9)

    {

    int col = 1;

    while (col <= row)

    {

    printf("%d * %d = %d\t", col, row, col * row);

    col += 1;

    }

    printf("\n");

    row += 1;

    }

    printf("\n");

    return 0;

    运行结果

    1 * 1 = 1

    1 * 2 = 2 2 * 2 = 4

    1 * 3 = 3 2 * 3 = 6 3 * 3 = 9

    1 * 4 = 4 2 * 4 = 8 3 * 4 = 12 4 * 4 = 16

    1 * 5 = 5 2 * 5 = 10 3 * 5 = 15 4 * 5 = 20 5 * 5 = 25

    1 * 6 = 6 2 * 6 = 12 3 * 6 = 18 4 * 6 = 24 5 * 6 = 30 6 * 6 = 36

    1 * 7 = 7 2 * 7 = 14 3 * 7 = 21 4 * 7 = 28 5 * 7 = 35 6 * 7 = 42 7 * 7 = 49

    1 * 8 = 8 2 * 8 = 16 3 * 8 = 24 4 * 8 = 32 5 * 8 = 40 6 * 8 = 48 7 * 8 = 56 8 * 8 = 64

    1 * 9 = 9 2 * 9 = 18 3 * 9 = 27 4 * 9 = 36 5 * 9 = 45 6 * 9 = 54 7 * 9 = 63 8 * 9 = 72 9 * 9 = 81

    更多相关内容
  • 文章目录目的:使用 for 循环嵌套:使用 while 循环实现:    此链接通往 Bash Shell 编程学习的目录导航 ,从入门到放弃,感兴趣的可以去看看: 目的: 实现 打印 99乘法: 1*1=1 1*2=2 2*2=4 1*3=3 2*3=6 3*...
  • while循环九九乘法、do.while循环九九乘法、for循环_九九乘法
  • python while 循环打印九九乘法

    千次阅读 2020-12-01 17:59:20
    方向一i = 1while i <= 9:j = 1while j <= iprint(‘%d*%d = %2d‘%( j,i ,i*j),end=‘‘)j += 1print()i += 1思路:先写出列,从一到九,再写出列,每次行=列的时候换行,行数增加一,所以里面的while循环是 ...

    方向一

    i = 1

    while i <= 9:

    j = 1

    while j <= i

    print(‘%d*%d = %2d‘%( j,i ,i*j),end=‘‘)

    j += 1

    print()

    i += 1

    思路:先写出列,从一到九,再写出列,每次行=列的时候换行,行数增加一,所以里面的while循环是 j <= i,当行数小于列数时,执行换行代码,进行下一轮的循环,end = ‘’ 表示不换行继续往下写

    方向一打印结果示例

    1*1 = 1

    1*2 = 2 2*2 = 4

    1*3 = 3 2*3 = 6 3*3 = 9

    1*4 = 4 2*4 = 8 3*4 =12 4*4 =16

    1*5 = 5 2*5 =10 3*5 =15 4*5 =20 5*5 =25

    1*6 = 6 2*6 =12 3*6 =18 4*6 =24 5*6 =30 6*6 =36

    1*7 = 7 2*7 =14 3*7 =21 4*7 =28 5*7 =35 6*7 =42 7*7 =49

    1*8 = 8 2*8 =16 3*8 =24 4*8 =32 5*8 =40 6*8 =48 7*8 =56 8*8 =64

    1*9 = 9 2*9 =18 3*9 =27 4*9 =36 5*9 =45 6*9 =54 7*9 =63 8*9 =72 9*9 =81

    方向二

    i = 1

    while i <= 9:

    k = 1

    while k <= 9 - i:

    print(‘ ‘,end = ‘ ‘)

    k += 1

    j = 1

    while j <= i

    print(‘%d*%d = %2d‘%( j,i ,i*j),end=‘‘)

    j += 1

    print()

    i += 1

    思路:方向二相对于方向一,需要在前面打印空格,且每次打印的空格跟行数有关,这时就需要一个循环,使得前面的空格被打印出来

    方向一打印结果示例

    1*1 = 1

    1*2 = 2 2*2 = 4

    1*3 = 3 2*3 = 6 3*3 = 9

    1*4 = 4 2*4 = 8 3*4 =12 4*4 =16

    1*5 = 5 2*5 =10 3*5 =15 4*5 =20 5*5 =25

    1*6 = 6 2*6 =12 3*6 =18 4*6 =24 5*6 =30 6*6 =36

    1*7 = 7 2*7 =14 3*7 =21 4*7 =28 5*7 =35 6*7 =42 7*7 =49

    1*8 = 8 2*8 =16 3*8 =24 4*8 =32 5*8 =40 6*8 =48 7*8 =56 8*8 =64

    1*9 = 9 2*9 =18 3*9 =27 4*9 =36 5*9 =45 6*9 =54 7*9 =63 8*9 =72 9*9 =81

    方向三

    i = 9

    while i >= 1:

    j = 1

    while j <= i

    print(‘%d*%d = %2d‘%( j,i ,i*j),end=‘‘)

    j += 1

    print()

    i -= 1

    思路:方向三中的i是从9到1,然后再是把i一个一个往下减

    方向三打印结果示例

    1*9 = 9 2*9 =18 3*9 =27 4*9 =36 5*9 =45 6*9 =54 7*9 =63 8*9 =72 9*9 =81

    1*8 = 8 2*8 =16 3*8 =24 4*8 =32 5*8 =40 6*8 =48 7*8 =56 8*8 =64

    1*7 = 7 2*7 =14 3*7 =21 4*7 =28 5*7 =35 6*7 =42 7*7 =49

    1*6 = 6 2*6 =12 3*6 =18 4*6 =24 5*6 =30 6*6 =36

    1*5 = 5 2*5 =10 3*5 =15 4*5 =20 5*5 =25

    1*4 = 4 2*4 = 8 3*4 =12 4*4 =16

    1*3 = 3 2*3 = 6 3*3 = 9

    1*2 = 2 2*2 = 4

    1*1 = 1

    方向四

    i = 9

    while i >= 1:

    k = 1

    while k <= 9-i:

    print(‘ ‘, end = ‘ ‘)

    k += 1

    j = 1

    while j <= i

    print(‘%d*%d = %2d‘%( j,i ,i*j),end=‘‘)

    j += 1

    print()

    i -= 1

    思路:和方向二类似,在方向三的基础上,在前面根据行数打印一定量的空格就可以了

    方向四打印结果示例

    1*9 = 9 2*9 =18 3*9 =27 4*9 =36 5*9 =45 6*9 =54 7*9 =63 8*9 =72 9*9 =81

    1*8 = 8 2*8 =16 3*8 =24 4*8 =32 5*8 =40 6*8 =48 7*8 =56 8*8 =64

    1*7 = 7 2*7 =14 3*7 =21 4*7 =28 5*7 =35 6*7 =42 7*7 =49

    1*6 = 6 2*6 =12 3*6 =18 4*6 =24 5*6 =30 6*6 =36

    1*5 = 5 2*5 =10 3*5 =15 4*5 =20 5*5 =25

    1*4 = 4 2*4 = 8 3*4 =12 4*4 =16

    1*3 = 3 2*3 = 6 3*3 = 9

    1*2 = 2 2*2 = 4

    1*1 = 1

    展开全文
  • python while九九乘法

    千次阅读 2018-12-04 22:54:27
    while i&lt;=9: j=1 while j&lt;i: print(" ",end='\t') j += 1 k=10-i while k&gt;=1: print("%dx%d=%2d"%((10-i),k,(10-i)*k),end="\t") k -= 1 p...
    i = 1
    while i<=9:
        j=1
        while j<i:
            print("     ",end='\t')
            j += 1
        k=10-i
        while k>=1:
            print("%dx%d=%2d"%((10-i),k,(10-i)*k),end="\t")
            k -= 1
        print()
        i += 1
    
    
    9x9=81	9x8=72	9x7=63	9x6=54	9x5=45	9x4=36	9x3=27	9x2=18	9x1= 9	
         	8x8=64	8x7=56	8x6=48	8x5=40	8x4=32	8x3=24	8x2=16	8x1= 8	
         	     	7x7=49	7x6=42	7x5=35	7x4=28	7x3=21	7x2=14	7x1= 7	
         	     	     	6x6=36	6x5=30	6x4=24	6x3=18	6x2=12	6x1= 6	
         	     	     	     	5x5=25	5x4=20	5x3=15	5x2=10	5x1= 5	
         	     	     	     	     	4x4=16	4x3=12	4x2= 8	4x1= 4	
         	     	     	     	     	     	3x3= 9	3x2= 6	3x1= 3	
         	     	     	     	     	     	     	2x2= 4	2x1= 2	
         	     	     	     	     	     	     	     	1x1= 1	
    
    i = 9
    while i >= 1:
        j = 1
        while j<=i:
            print("%dx%d=%-2d"%(j,i,j*i),end=("\t"))
            j += 1
        print()
        i -= 1
    
    1x9=9 	2x9=18	3x9=27	4x9=36	5x9=45	6x9=54	7x9=63	8x9=72	9x9=81	
    1x8=8 	2x8=16	3x8=24	4x8=32	5x8=40	6x8=48	7x8=56	8x8=64	
    1x7=7 	2x7=14	3x7=21	4x7=28	5x7=35	6x7=42	7x7=49	
    1x6=6 	2x6=12	3x6=18	4x6=24	5x6=30	6x6=36	
    1x5=5 	2x5=10	3x5=15	4x5=20	5x5=25	
    1x4=4 	2x4=8 	3x4=12	4x4=16	
    1x3=3 	2x3=6 	3x3=9 	
    1x2=2 	2x2=4 	
    1x1=1 
    
    i = 1
    while i<= 9:
        j = 1
        while j <= i:
            sum = j*i
            print("%dx%d=%2d"%(j,i,sum),end=("\t"))
            j += 1
        print()
        i += 1
    
    1x1= 1	
    1x2= 2	2x2= 4	
    1x3= 3	2x3= 6	3x3= 9	
    1x4= 4	2x4= 8	3x4=12	4x4=16	
    1x5= 5	2x5=10	3x5=15	4x5=20	5x5=25	
    1x6= 6	2x6=12	3x6=18	4x6=24	5x6=30	6x6=36	
    1x7= 7	2x7=14	3x7=21	4x7=28	5x7=35	6x7=42	7x7=49	
    1x8= 8	2x8=16	3x8=24	4x8=32	5x8=40	6x8=48	7x8=56	8x8=64	
    1x9= 9	2x9=18	3x9=27	4x9=36	5x9=45	6x9=54	7x9=63	8x9=72	9x9=81
    
    i = 9
    while i>=1:
        k = 1
        while k <= 9-i:
            print('     ',end="\t")
            k += 1
        j = 1
        while j<=i:
            print("%dx%d=%2d"%(j,i,j*i),end=("\t"))
            j += 1
        print()
        i -=1
    
    1x9= 9	2x9=18	3x9=27	4x9=36	5x9=45	6x9=54	7x9=63	8x9=72	9x9=81	
         	1x8= 8	2x8=16	3x8=24	4x8=32	5x8=40	6x8=48	7x8=56	8x8=64	
         	     	1x7= 7	2x7=14	3x7=21	4x7=28	5x7=35	6x7=42	7x7=49	
         	     	     	1x6= 6	2x6=12	3x6=18	4x6=24	5x6=30	6x6=36	
         	     	     	     	1x5= 5	2x5=10	3x5=15	4x5=20	5x5=25	
         	     	     	     	     	1x4= 4	2x4= 8	3x4=12	4x4=16	
         	     	     	     	     	     	1x3= 3	2x3= 6	3x3= 9	
         	     	     	     	     	     	     	1x2= 2	2x2= 4	
         	     	     	     	     	     	     	     	1x1= 1	
    
    i = 1
    while i<=9:
        k = 1
        while k <= 9-i:
            print('     ',end="\t")
            k += 1
        j = 1
        while j<=i:
            print("%dx%d=%2d"%(j,i,j*i),end=("\t"))
            j += 1
        print()
        i +=1
    
         	     	     	     	     	     	     	     	1x1= 1	
         	     	     	     	     	     	     	1x2= 2	2x2= 4	
         	     	     	     	     	     	1x3= 3	2x3= 6	3x3= 9	
         	     	     	     	     	1x4= 4	2x4= 8	3x4=12	4x4=16	
         	     	     	     	1x5= 5	2x5=10	3x5=15	4x5=20	5x5=25	
         	     	     	1x6= 6	2x6=12	3x6=18	4x6=24	5x6=30	6x6=36	
         	     	1x7= 7	2x7=14	3x7=21	4x7=28	5x7=35	6x7=42	7x7=49	
         	1x8= 8	2x8=16	3x8=24	4x8=32	5x8=40	6x8=48	7x8=56	8x8=64	
    1x9= 9	2x9=18	3x9=27	4x9=36	5x9=45	6x9=54	7x9=63	8x9=72	9x9=81
    
    展开全文
  • 方法一:1 i = 12 while i < 10:3 k = 14 while k <= i:5 print('%d*%d=%2d '% (i,k,i*k),end='') #end=‘’ 表示不换行(系统默认输出完毕换行)6 k += 17 print()8 i += 1输出结果9 1*1= 110 2*1= 2 2...

    方法一:

    1    i = 1

    2    while i < 10:

    3     k = 1

    4     while k <= i:

    5    print('%d*%d=%2d   '% (i,k,i*k),end='') #end=‘’  表示不换行(系统默认输出完毕换行)

    6    k += 1

    7    print()

    8     i += 1

    输出结果

    9 1*1= 1

    10  2*1= 2   2*2= 4

    11  3*1= 3   3*2= 6   3*3= 9

    12  4*1= 4   4*2= 8   4*3=12   4*4=16

    13  5*1= 5   5*2=10   5*3=15   5*4=20   5*5=25

    14  6*1= 6   6*2=12   6*3=18   6*4=24   6*5=30   6*6=36

    15 7*1= 7   7*2=14   7*3=21   7*4=28   7*5=35   7*6=42   7*7=49

    16  8*1= 8   8*2=16   8*3=24   8*4=32   8*5=40   8*6=48   8*7=56   8*8=64

    17  9*1= 9   9*2=18   9*3=27   9*4=36   9*5=45   9*6=54   9*7=63   9*8=72   9*9=81

    923ae6d2cd850d6582e6c305732801bf.png

    方法二、

    1    a = 9

    2   while a > 0:

    3    i = 1

    4    while i <= a:

    5   print('%d * %d = %2d  '%(a,i,a*i),end= '')

    6   i += 1

    7   print()

    8   a -= 110 11

    输出结果:

    9     9 * 1 =  9  9 * 2 = 18  9 * 3 = 27  9 * 4 = 36  9 * 5 = 45  9 * 6 = 54  9 * 7 = 63  9 * 8 = 72  9 * 9 = 81

    10   9 * 1 =  9  9 * 2 = 18  9 * 3 = 27  9 * 4 = 36  9 * 5 = 45  9 * 6 = 54  9 * 7 = 63  9 * 8 = 72  9 * 9 = 81

    11   8 * 1 =  8  8 * 2 = 16  8 * 3 = 24  8 * 4 = 32  8 * 5 = 40  8 * 6 = 48  8 * 7 = 56  8 * 8 = 64

    12   7 * 1 =  7  7 * 2 = 14  7 * 3 = 21  7 * 4 = 28  7 * 5 = 35  7 * 6 = 42  7 * 7 = 49

    13   6 * 1 =  6  6 * 2 = 12  6 * 3 = 18  6 * 4 = 24  6 * 5 = 30  6 * 6 = 36

    14   5 * 1 =  5  5 * 2 = 10  5 * 3 = 15  5 * 4 = 20  5 * 5 = 25

    15   4 * 1 =  4  4 * 2 =  8  4 * 3 = 12  4 * 4 = 16

    16   3 * 1 =  3  3 * 2 =  6  3 * 3 =  9

    17   2 * 1 =  2  2 * 2 =  4

    18   1 * 1 =  1

    展开全文
  • python while循环实现九九乘法

    千次阅读 2020-09-07 16:36:19
    while循环实现九九乘法 代码如下: i = 1 j = 1 while i< 10: while j<(i+1): print("%d*%d=%d"%(j,i,i*j),end="\t") j=j+1 print() i=i+1 j=1 效果如下: 这里需要注意的是制表符end="\t" ...
  • #include<stdio.h> int main (){ int i=1,j; do{ j=1; do{ printf("%d*%d=%d ",i,j,i*j); j++; }while(j<=i); i++; printf("\n"); }while(i<=9); }
  • while循环写九九乘法

    千次阅读 2021-09-07 10:34:02
    i=1 while i<=9: print() z=0 while z<i:#通过z与i的大小关系来控制循环次数 z+=1 x=i*z print(i,"*",z,"=",x,end="\t") i += 1
  • python while循环——实现99乘法

    千次阅读 2021-06-25 09:10:33
    首先,放出while循环的基本语法格式: i = 1 # 循环的初始值 while i<=10: # 循环的判断条件 if i==5: ## break # 提前终止循环,跳出当前代码块 i += 1 #因为语句中有continue, # 才有这条语法,否则...
  • 利用循环语句while打印输出九九乘法 #include<stdio.h> int main() { int c , i = 1 , j = 1 ;//定义变量c,i,j while( i<=9 ) { j = 1 ; while( j<=i ) { c = i * j ; printf(" %d * %d = %d ...
  • while语句来输出九九乘法 while(i) {j=1; while(j) {if(j) {printf("%3d*%d=%2d",i,j,i*j); j++; } else break; } i++; putchar('\n'); }
  • 方法一i = 1while i < 10:k = 1while k <= i:print('%d*%d=%2d '% (i,k,i*k),end='') #end=‘’ 表示不换行(系统默认输出完毕换行)k += 1print()i += 1输出结果1*1= 12*1= 2 2*2= 43*1= 3 3*2= 6 3*3= 94*1= 4...
  • 一、9x9乘法(包含4种算法) do while() 正的 9X9 int i = 1; int j = 1; do { j = 1; while (j ) { //控制列 System.out.print(i + "*" + j + "=" + i*j + " "); j++; } System.out.println(""); i++; } ...
  • do-while实现九九乘法

    千次阅读 2020-07-19 20:10:45
    public class DoWhilejiujiu { public static void main...while(j<=i){ int a = ij ; System.out.print(i+""+j+"="+a+" “); if(i==j) { System.out.print(”\n"); } j++; } i++; } while (i <= 9); } } ...
  • while循环实现九九乘法

    千次阅读 2019-07-12 14:14:00
    #!/usr/bin/python#coding=utf-8#while99i=1while i<10: j=1 while j<=i: print str(j)+'×'+str(i)+'='+str(i*j), j=j+1 print ' ' ...
  • 利用 while循环和for循环输出 九九乘法 while 循环 i = 1 while i <= 9: j = 1 while j<=i: print(j, "*", i, "=", i*j, end=" ") j = j + 1 # 这个print是换行 print() i = i + 1 for循环 for...
  • 使用while循环打印出九九乘法

    千次阅读 2021-04-07 14:16:58
    使用while循环打印出九九乘法 思路:先定义出一个行等于1 当行row <= 9的前提下,定义列等于1 当列col <= row的前提下进行格式化输出 这里同样使用end设置结尾符号,并加入横向制表符end=’\t’ 当每一行的每一...
  • java语言编写的九九乘法,for、while两种编写
  • while语句实现九九乘法

    千次阅读 2019-11-04 23:39:05
    如代码所示 #include <stdio.h> int main() { ... while(i<=9) { j=1; while(j<=i) { printf("%d*%d=%d",j,i,i*j); printf(" "); j++; } printf("\n"); i++; } return 0...
  • for, do while, while写的九九乘法 for循环写的打印菱形,正方形 for循环打印的求和等 最全的for学习资料
  • java语言基础用while循环做99乘法

    千次阅读 2020-08-06 19:05:41
    package day04; public class multiplicationTable { public static void main(String[] args) { ... while(i<=9){ num=1; while(num<=i){ System.out.print(num+"*"+i+"="+i*num+"\...
  • while练习——九九乘法

    千次阅读 2018-11-22 11:15:44
    1.利用while语句编写九九乘法 代码编译: 运行测试:
  • while循环打印9x9乘法,使用两个嵌套循环,一个控制行,一个控制列,其代码如下: i=1#行控制 while i&lt;=9: j = 1#列控制 while j&lt;=i: print("%dx%d=%d"%(i,j,i*j),end=' ') j=j+1 ...
  • while循环脚本实现九九乘法

    千次阅读 2020-04-12 14:39:19
    for循环和while他俩都可以实现并且的功能是一样的 根据自己喜好选择使用
  • 用for循环 while循环 实现九九乘法

    千次阅读 2018-12-16 23:08:54
    JS代码: //for循环 &...点击显示九九乘法&lt;/button&gt; &lt;script&gt; function operations(){  for(var i = 1;i &lt;10;i++){  for(var j = 1;j&lt...
  • while的用法_C语言中while的用法

    万次阅读 2021-05-19 05:44:46
    c语言中while的用法当n==1时执行while循环结构里的语句,当n不等于1时,则跳过该循环执行循环体外的语句。while 循环的格式:while (表达式){语句;}while 循环的执行顺序:当表达式为真,则执行下面的语句,语句...
  • num = 1 while num &amp;amp;amp;lt;= 100: print('现在的数字为',num) num += 1 结果如图:
  • python中while循环打印99乘法

    万次阅读 多人点赞 2019-01-21 14:33:10
    花式打印9*9乘法 #第一个计数器 i = 1 while i &lt; 10: #第二个计数器 j = 1 while j &lt;= i: print('%d*%d=%d\t' %(j, i, i*j) , end=('')) j +=1 #换行 print('') i +=1 #输出换行 print(''...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 1,387,196
精华内容 554,878
关键字:

while表尽管