在 c 中使用 while 循环查找 a1z、b2y、c3x、...、...、....、nnn 的斐波那契数列的程序?

Program to find fibonacci series of a1z,b2y,c3x,...,...,....,nnn using while loop in c?

该系列混合了多字符和整数,那么打印输出的代码是什么?

#include<stdio.h>
int main(){
    int fi=0;
    while(fi<=26)
    {
        if(fi>=97||fi<=122||fi>=1)
    {
    printf("%c%d%c",fi);
    }
    fi++;
    }
     return 0;
}

我试过这段代码但没有输出

此处不应使用 int fi='a1z';,而应使用从 0 开始到 26 结束的计数器。

你也不能这样使用printf。它不像某些其他语言那样是某种通用格式化工具,您有 一个 格式字符串,剩下的就是您要打印的内容。

这可能是您想要执行的操作:

#include <stdio.h>

int main(void)
{
    int ctr;
    for(ctr = 0; ctr < 26; ctr++)
    {
        printf("%c%d%c\n", 'a' + ctr, ctr + 1, 'z' - ctr);
    }
    return 0;
}
#include <stdio.h>

int main(void)
{
    int ctr;
    for(ctr = 0; ctr < 26; ctr++)
    {
        printf("%c%d%c\n", 'a' + ctr, ctr + 1, 'z' - ctr);
    }
    return 0;
}

问题已解决:我们不会使用单引号,因为 0 不是字符。

使用 while 循环


#include<stdio.h>
int main(){
     int fi=0;
     while(fi<26)
     {
         printf("%c%d%c",'a'+fi,fi+1,'z'-fi);
     fi++;
     }
}