asterick作业问题 [英] asterick homework problem

查看:92
本文介绍了asterick作业问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到合适的源代码:

输出应该是:


问题编号1)。

输入星号数:5

*

**

***

* ***

*****

再试一次?[是/否]:__


---- -------------------------------------------------- -

问题编号2)。

输入星号数:5

*****

* ***

***

**

*

再试一次?[是/否]: __

i couldn''t find out the right source code for this one:
output should be:

problem number 1).
enter number of asterisks:5
*
**
***
****
*****
try again?[Y/N]: __

-------------------------------------------------------
problem number 2).
enter number of asterisks:5
*****
****
***
**
*
try again?[Y/N]: __

推荐答案

到目前为止你写了什么?你有什么想法?为了解决这个问题,你做了什么?
What have you written so far? What ideas do you have? What have you done in an effort to solve this problem alone?



你到目前为止写了什么?你有什么想法?你为解决这个问题而做了什么?
What have you written so far? What ideas do you have? What have you done in an effort to solve this problem alone?



我只编码了这个:


#include< stdio.h>

#include< ; conio.h>

void main(无效)

{

int x,y;

char choice ;

do {

clrscr();

printf("输入星号:");

scanf("%i"& y);

for(x = 1; x< = y; x ++)

{

gotoxy(x * 1,x * 1 + 2); cprintf(" *");

}

printf(" \ ntry再次[是/否]:");

choice = getch();

} while(choice ==''Y''|| choice =='' y'');

getch();

}


,输出为:

*

*

*


所需输出为:


输入星号: 3

*

**

***

再试一次[y / n]:__


,另一个是这样的:

输入星号数: 3

***

**

*

再试一次[是/否]:__

$ b $你可以帮帮我吗...我知道你可以

i只剩下一点时间;

明天会提交......

非常感谢!!!

I just encoded this:

#include<stdio.h>
#include<conio.h>
void main (void)
{
int x,y;
char choice;
do{
clrscr();
printf("Enter number of asterisk:");
scanf("%i",&y);
for(x=1;x<=y;x++)
{
gotoxy(x*1,x*1+2);cprintf("*");
}
printf("\ntry again [Y/N]:");
choice=getch();
}while(choice==''Y'' || choice==''y'');
getch();
}

and the output is:
*
*
*

the output required is:

Enter number of asterisks: 3
*
**
***
try again [y/n]: __

and the other one goes like this:
Enter number of asterisks: 3
***
**
*
try again [y/n]: __

can you help me pls..i know you can
i just got a little time left;
submission will be tomorrow...
thanks alot!!!


#include< stdio.h>

#include< conio.h>

int main ()

{

int i,j,k;

char ch;

clrscr();

printf("输入no:");

scanf("%d",& i);

for( k = 0; k <= i; k ++)

{

for(j = 0; j< k; j ++)

{< br $> b $ b printf(" *");

}

printf(" \ n");

}


printf(" Second Format ..... \ n");

for(k = 0; k< = i; k ++)

{

for(j = i; j> k; j--)

{

printf(" *");

}

printf(" \ n");

}

printf(按任意键继续.... \ n);

getch();

返回0; < br $>
}



以上代码将同时生成1和2个任务....

实现该操作直到用户按下N ....将整个程序放入Do-While循环....


循环应该在clrscr()之后开始并在按下之前结束任何键继续....


尝试....
#include <stdio.h>
#include <conio.h>
int main()
{
int i,j,k;
char ch;
clrscr();
printf("Enter the no : ");
scanf("%d",&i);
for(k=0;k<=i;k++)
{
for(j=0;j<k;j++)
{
printf("*");
}
printf("\n");
}

printf("Second Format.....\n");
for(k=0;k<=i;k++)
{
for(j=i;j>k;j--)
{
printf("*");
}
printf("\n");
}
printf("Press any key to continue....\n");
getch();
return 0;
}



The above code will generate as both 1 and 2 tasks....
Implement that to continue till user press N....By putting whole program in the Do-While loop....

Loop should start after clrscr() and ends before press anykey to continue....

Try....


这篇关于asterick作业问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆