C语言 for嵌套如何改写为while嵌套

虽然查找到的大部分回答都是“循环结构for能和while进行互换”,但是感觉有个地方的确无法互换。

下面是用for写的,能够输出4组数字:
1 1
1 2
2 1
2 2

 #include <stdio.h>
void main()
{
    int a,b;
    for(a=1;a<=2;a++)
        for(b=1;b<=2;b++)
            printf("%d %d\n",a,b);
}

下面是用while写的:

#include <stdio.h>
void main()
{
    int a=1,b=1;
    while(a<=1)
    {
        a++;
        while(b<=1)
        {
            b++;
            printf("%d %d\n",a,b);
        }
    }
}

输出结果大不相同。
while结构中能否不添加其余变量等,使得输出结果和for输出一样?

 #include <stdio.h>
void main()
{
    int a,b;
        a=1
    while(a<=2)
        {
            b=1;
        while(b<=2)
                {
            printf("%d %d\n",a,b);
                    b++;
                }
            a++;
        }
}

参考我在 http://ask.csdn.net/questions/254265 的回答。

这里的for嵌套,有三个,总觉得不能用,但后来想想 它是能运行的,因为C语言中的程序是顺序执行的,第一个被执行完成后,接着执行第二个,用相同的时间,所以没有问题
#include <reg52.H>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
//心形......
答案就在这里:单片机编程C语言 好多for嵌套
----------------------Hi,地球人,我是问答机器人小S,上面的内容就是我狂拽酷炫叼炸天的答案,除了赞同,你还有别的选择吗?

#include
void main()
{
int a,b;
a=1
while(a<=2)
{
b=1;
while(b<=2)
{
printf("%d %d\n",a,b);
b++;
}
a++;
}
} 这个回答好点

你没理解for的原理,括号里面三条语句,先是执行一二两条,之后执行for循环体,最后执行最后第三条语句。。。所以你是顺序有问题,导致结果不一样。。。