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;
}
相关推荐
思考的笛卡尔1 小时前
密码学基础:RSA与AES算法的实现与对比
网络·算法·密码学
C嘎嘎嵌入式开发5 小时前
(2)100天python从入门到拿捏
开发语言·python
Stanford_11065 小时前
如何利用Python进行数据分析与可视化的具体操作指南
开发语言·c++·python·微信小程序·微信公众平台·twitter·微信开放平台
Vallelonga6 小时前
Rust 中的数组和数组切片引用
开发语言·rust
Kiri霧6 小时前
Rust模式匹配详解
开发语言·windows·rust
white-persist7 小时前
Python实例方法与Python类的构造方法全解析
开发语言·前端·python·原型模式
千里马-horse7 小时前
Async++ 源码分析8--partitioner.h
开发语言·c++·async++·partitioner
格林威7 小时前
常规线扫描镜头有哪些类型?能做什么?
人工智能·深度学习·数码相机·算法·计算机视觉·视觉检测·工业镜头
Lucis__7 小时前
再探类&对象——C++入门进阶
开发语言·c++
007php0077 小时前
某大厂跳动面试:计算机网络相关问题解析与总结
java·开发语言·学习·计算机网络·mysql·面试·职场和发展