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;
}
相关推荐
禹凕8 小时前
Python编程——进阶知识(多线程)
开发语言·爬虫·python
铉铉这波能秀8 小时前
LeetCode Hot100数据结构背景知识之字典(Dictionary)Python2026新版
数据结构·python·算法·leetcode·字典·dictionary
蜡笔小马8 小时前
10.Boost.Geometry R-tree 空间索引详解
开发语言·c++·算法·r-tree
IOsetting8 小时前
金山云主机添加开机路由
运维·服务器·开发语言·网络·php
唐梓航-求职中8 小时前
编程-技术-算法-leetcode-288. 单词的唯一缩写
算法·leetcode·c#
仟濹8 小时前
【算法打卡day3 | 2026-02-08 周日 | 算法: BFS】3_卡码网99_计数孤岛_BFS | 4_卡码网100_最大岛屿的面积DFS
算法·深度优先·宽度优先
Ll13045252988 小时前
Leetcode二叉树part4
算法·leetcode·职场和发展
林开落L8 小时前
从零开始学习Protobuf(C++实战版)
开发语言·c++·学习·protobuffer·结构化数据序列化机制
牛奔8 小时前
Go 是如何做抢占式调度的?
开发语言·后端·golang
颜酱8 小时前
二叉树遍历思维实战
javascript·后端·算法