在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 送给学长毕业祝福语简短