在C中不使用循环,递归和宏扩展即可打印100次
在本节中,我们将看到如何在C中打印数字100次。存在一些约束。我们不能使用循环,递归或宏扩展。
为了解决这个问题,我们将使用C的的setjump和跳远踏板setjump()和longjump()位于SETJMP.H库。这两个函数的语法如下。
示例
#include <stdio.h>
#include <setjmp.h>
jmp_buf buf;
main() {
int x = 1;
setjmp(buf); //set the jump position using buf
printf("5"); // Prints a number
x++;
if (x <= 100)
longjmp(buf, 1); // Jump to the point located by setjmp
}输出结果
5555555555555555555555555555555555555555555555555555555555555555555555555555 555555555555555555555555
热门推荐
10 毛笔哥哥结婚祝福语简短
11 向国庆送祝福语简短
12 建队节祝福语简短
13 朋友喜得外孙简短祝福语
14 小店营业的祝福语简短
15 餐饮生日祝福语简短独特
16 鲜花英语祝福语卡片简短
17 男朋友暴富祝福语简短
18 婶婶拜年祝福语大全简短