需要帮助.....请在c中给出一些嵌套for循环的例子 [英] Need help ..... Please give some examples of nested for loop in c
本文介绍了需要帮助.....请在c中给出一些嵌套for循环的例子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hai all,
你好吗?祝你好。
你能给我一些嵌套for循环的例子吗?这是紧急的.plz帮助。
谢谢
解决方案
你可以在google上搜索
https://www.google.co.in/ ?gfe_rd = cr& ei = Zl3PU6ySOarV8gfjooGACQ #q = example + nested + for + loop + in + c [ ^ ]
以下是示例
#include < stdio.h >
#include < conio.h >
main()
{
int i,j,lines;
char ch = ' *'跨度>;
clrscr();
printf( 输入行数:);
scanf( %d,& lines);
for (i = 0 ; i< = lines; i ++)
{
printf( n);
for (j = 0 ; j< i; j ++)
printf ( %c,ch);
}
getch();
}
< /conio.h>< /stdio.h>
输出为< br $>
*
* *
* * *
* * * *
* * * * *
* * * * * *
#include < stdio.h >
int main()
{
int row,c,n,temp;
printf( 输入您希望看到的星座金字塔中的行数< /跨度>);
scanf( %d,& n);
temp = n;
for (row = 1 ; row< = n; row ++)
{
for (c = 1 ; c< temp; c ++)
printf( );
temp--;
for (c = 1 ; c< = 2 * row - 1 ; c ++)
printf( *);
printf( \ n);
}
return 0 ;
}
< /stdio.h>
输出
*
***
*****
*******
*********
#include< stdio.h>
int main()
{
int c,d;
c = 1;
而(c <= 10)
{
d = 1;
while(d< = c)
{
printf(*);
d = d + 1; }
printf(:\ n);
c = c + 1;
}
}
Hai all,
How are you ? wishing you fine.
Can you give some me examples of nested for loop in c ? It is urgent .plz help.
Thanks
解决方案
You can search on google as
https://www.google.co.in/?gfe_rd=cr&ei=Zl3PU6ySOarV8gfjooGACQ#q=example+nested+for+loop+in+c[^]
Following is the examples
#include<stdio.h> #include<conio.h> main() { int i,j,lines; char ch = '*'; clrscr(); printf("Enter number of lines : "); scanf("%d",&lines); for(i=0;i <=lines;i++) { printf("n"); for (j=0;j < i;j++) printf("%c",ch); } getch(); } </conio.h></stdio.h>
the output is
*
* *
* * *
* * * *
* * * * *
* * * * * *
#include <stdio.h> int main() { int row, c, n, temp; printf("Enter the number of rows in pyramid of stars you wish to see "); scanf("%d",&n); temp = n; for ( row = 1 ; row <= n ; row++ ) { for ( c = 1 ; c < temp ; c++ ) printf(" "); temp--; for ( c = 1 ; c <= 2*row - 1 ; c++ ) printf("*"); printf("\n"); } return 0; } </stdio.h>
Output
*
***
*****
*******
*********
#include <stdio.h>
int main()
{
int c,d;
c=1;
while(c<=10)
{
d=1;
while(d<=c)
{
printf("*");
d=d+1; }
printf(:\n");
c=c+1;
}
}
这篇关于需要帮助.....请在c中给出一些嵌套for循环的例子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文