首页  >  文章  >  后端开发  >  如何使用for循环或while循环按顺序编写?

如何使用for循环或while循环按顺序编写?

WBOY
WBOY转载
2023-09-06 22:45:061046浏览

如何使用for循环或while循环按顺序编写?

示例

#include
#include
void main() {
   int i,j,a=0,b=1,n;
   clrscr();
   printf("****************OUTPUT*****************</p><p></p><p>");
   printf("enter the value of n : ");
   scanf("%d",&n);
   printf("</p><p> the required order is: </p><p></p><p>" );

   for(i=1;i<=n;i++) {
      if(i==1)
      printf("%d. E",i);
      else {
         printf("%d. ",i);
         for(j=1;j<=i-1;j++)
         printf("%d",a);

         for(j=1;j<=i-1;j++)
         printf("%d",b);
      }
      printf("</p><p>");
   }
   getch();
}

以上是如何使用for循环或while循环按顺序编写?的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文转载于:tutorialspoint.com。如有侵权,请联系admin@php.cn删除