在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 教师闺蜜祝福语简短