C控制语句:循环(终章·答案)

1:

cpp 复制代码
#include <stdio.h>
int main(void)
{
	int i;
	char number[26];
	char c = 'a';
	for ( i = 0; i < 26; i++, c++)
	{
		number[i] = c;
	}
	for (i = 0; i < 26; i++)
	{
		printf("%c", number[i]);
	}
	return 0;
}

2:

cpp 复制代码
#include <stdio.h>
int main(void)
{
	for (int i = 1; i < 6; i++)
	{

		for (int a = 0; a <i ; a++)
		{
			printf("$");
		}
		printf("\n");
	
	}
	return 0;
}

3:

cpp 复制代码
#include <stdio.h>
int main(void)
{
	int j, i;
	char c;
	for (int i = 0; i <= 6; i++)
	{

		for (j = 0,c = 'F';j<i;j++,c--)
		{
			printf("%c", c);
		}
		printf("\n");

	}
	return 0;
}

4:

cpp 复制代码
#include <stdio.h>
int main(void)
{
	int i, j;
	char c = 'A';//要使字母不重复,即不要让A在循环中;

	for (i = 1; i <= 6; i++)
	{
		for ( j = 0; j < i; j++, c++)
		{
			printf("%c", c);
		}
		printf("\n");
	}
	return 0;
}

5:

cpp 复制代码
#include <stdio.h>
int main(void)
{
	int i, j,k;
	char c;
	for ( i = 0; i < 5 ; i++)
	{
		for (j = 5; j > i; j--)
		{
			printf(" ");

		}
		for (c = 'A', k = 0; k <= i; c++,k++)
		{
			printf("%c", c);
		}
		for (k = i - 1, c = 'A' + k; k >= 0; k--, c--)
		{
			printf("%c", c);
		}
		printf("\n");

	}
	return 0;
}

6:

cpp 复制代码
int main(void)
{
    double YUAN = 1000000.0;  // 初始存款100万美元
    double LILV = 0.08;  // 年利率8%
    double TEN = 100000.0;  // 每年取款10万美元
    int years = 0;
    do
    {
        YUAN = YUAN + YUAN * LILV;
        YUAN -= TEN;
        years++;

    } while (YUAN > 9);
    printf("%d年后取完", years);
    return  0;
}
相关推荐
黄贵根11 分钟前
JavaScript实现教培行业意向登记系统
开发语言·javascript·ecmascript
zzzll11113 小时前
Claude Code离线安装方案揭秘
开发语言·php
wabs6663 小时前
关于图论【卡码网117.软件构建的思考】
数据结构·算法·软件构建·图论·卡码网
mifengxing4 小时前
LeetCode 41.缺失的第一个正数|Hard题O(n)+O(1)最优解法深度解析
java·算法·leetcode·排序算法
wling03014 小时前
vasp虚频计算-python脚本
开发语言·windows·python·vasp计算
郝学胜-神的一滴4 小时前
Qt 高级编程 040:按钮悬浮弹出滑块弹窗的完整攻略
开发语言·c++·qt·软件工程·用户界面
Tongzhi20264 小时前
从部署到运维:通芝科技无感考勤一体机的全流程效率解析
运维·数据结构·科技·算法·贪心算法
Wang's Blog5 小时前
AI Agent白手起家30: 动态示例选择器之根据长度选择 Few Shot 示例
算法
xrandzj5 小时前
Python面向对象编程入门:类、实例、初始化与封装实践
开发语言·python
DLYSB_6 小时前
API 网关流量洪峰与突发 CC 攻击:我用 Go 写了个“现场物理防御哨兵”,把故障响应压缩到秒级
开发语言·后端·golang·报警灯