C 练习实例88

C语言教程评论

C 练习实例88

题目:读取7个数(1—50)的整数值,每读取一个值,程序打印出该值个数的 *。

程序分析:无。文章源自公式库网-https://www.gongshiku.com/html/202112/c-lianxishili88.html

实例

#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n,i,j;
    printf("请输入数字:\n");i--;
    for(i=0;i<7;i++)
    {
        scanf("%d",&n);
        if(n>50){
            printf("请重新输入:\n");i--;
        }
        else
        {
            for(j=0;j<n;j++)
                printf("*");
        }
        printf("\n");
    }
    return 0;
}

以上实例运行输出结果为:文章源自公式库网-https://www.gongshiku.com/html/202112/c-lianxishili88.html

请输入数字:
5
*****
文章源自公式库网-https://www.gongshiku.com/html/202112/c-lianxishili88.html文章源自公式库网-https://www.gongshiku.com/html/202112/c-lianxishili88.html
运营不易,
感谢支持!
weinxin
我的微信
我的微信公众号
我的微信公众号扫一扫
weinxin
我的公众号
 最后更新:2021-12-7
公式库网
  • 本文由 公式库网 发表于 2021年12月6日21:21:04
  • 转载请务必保留本文链接:https://www.gongshiku.com/html/202112/c-lianxishili88.html

发表评论