学校排行榜

(0)

投一票

将 1~100 的数据以 10x10 矩阵格式输出。 官网

C 语言实例 - 表格形式输出数据 将 1~100 的数据以 10x10 矩阵格式输出。 实例 #include stdio.h int main() { int i, j, count; for(i = 1; i = 10; i++) { for(j = i; j =100; j += 10 ) printf(" %3d", j); printf("\n"); } return 0;} 尝试一下 运行结果: 1 11 21 31 41 51 61 71 81 912 12 22 32 42 52 62 72 82 923 13 23 33 43 53 63 73 83 934 14 24 34 44 54 64 74 84 945 15 25 35 45 55 65 75 85 956 16 26 36 46 56 66 76 86 967 17 27 37 47 57 67 77 87 978 18 28 38 48 58 68 78 88 989 19 29 39 49 59 69 79 89 9910 20 30 40 50 60 70 80 90 100 等差数列输出 10x10 矩阵格式。 实例 #include stdio.h int main() { int i, j, count; int start, end; start = 2, end = 10; for(i = start; i = end; i++) { count = i; for(j = 1; j = 10; j++) { printf(" %3d", count*j); } printf("\n"); } return 0;} 尝试一下 运行结果: 2 4 6 8 10 12 14 16 18 203 6 9 12 15 18 21 24 27 304 8 12 16 20 24 28 32 36 405 10 15 20 25 30 35 40 45 506 12 18 24 30 36 42 48 54 607 14 21 28 35 42 49 56 63 708 16 24 32 40 48 56 64 72 809 18 27 36 45 54 63 72 81 9010 20 30 40 50 60 70 80 90 100 乘法运算格式。 实例 #include stdio.h int main() { int i, j, n; n = 3; j = 1; for(i = n; i = (n*10); i+=n) { printf("%3d x %2d = %3d\n", n, j, i); j++; } return 0;} 尝试一下 运行结果: 3 x 1 = 33 x 2 = 63 x 3 = 93 x 4 = 123 x 5 = 153 x 6 = 183 x 7 = 213 x 8 = 243 x 9 = 273 x 10 = 30
专业
评论
新闻
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。