#C language Assignment 10

This work belongs to the curriculum C Programming Language II
Where the job requires [Job] ( https://edu.cnblogs.com/campus/zswxy/SE2019-1/homework/10099 )
My aim in this course is Familiar with break, continue the
This job helped me achieve that goal in terms of specific Learn defined functions, switch functions
references "C Programming Language"

PTA jobs

https://edu.cnblogs.com/campus/zswxy/SE2019-1/homework/10099

1.1 7-8 character array output triangle (15 minutes)

This problem requires programming, the output from the n-th row begins uppercase A triangular array of the character.

Input format:
input line in a given positive integer n (1≤n <7).

Output format:
a triangular array of characters output by the n-th row of capital letters A start configuration. See sample output format, where each letter has a back space.

Sample input:
4
Output Sample:
ABCD
EFG
the HI
J
1.1.1 experiment code screenshot

1.1,2 job submission

1.1.3 build test data

Input data Output Data Explanation
5 Description This triangle from AO
3 Description This triangle from the AF

1.1.4 Data processing and expression
data Expression: The definition of n, count, i, j, the number of letters per line number will be described with i, j with the number of rows to be described.
Data treatment: for-for a desired number of interspersed repeated use, until the output of the last letter.
Fake code

#include <stdio.h>       

int main()    
{
    int n, count = 0;                       //定义n,count
    scanf("%d", &n);                        //输入n
    for (int i = n; i > 0; i--) {           //对于每行的字母数进行减一运算
        for (int j = 0; j < i; j++) {       //对于有多少行进行计算
            printf("%c ", 'A' + count);     //输出A后面的第几个字母,count为多少,输出就为A后面第几个字母
            count++;                        //对于A后面第几个数字进行累加
        }
        printf("\n");                       //输出空行
    }
    return 0;                               //返回主函数
}

1.1.5 Operating Information
Q1: for j = 0 loop written j = n.

1.2题目名: 7-4 同构数 (10 分)

一个数恰好出现在它的平方数的右端,这个数就称为同构数。找出1~1000之间的全部同构数。

输出格式:
在一行中输出所有满足条件的同构数,每个数输出占6列。没有其它任何附加格式和字符。

输出样例:
1 5 6 25 76 376 625

1.2.1数据处理

数据表达:先搬出数学函数,在定义s,m,s用来累加,也就是对1~1000进行逐个算。
数据处理:然后用m对于s算的的条件进行承载,然后判断m的各个位数上是否有一个位数是等于s的。

伪代码

#include<stdio.h>
#include<math.h>                                              //数学函数的调用
int main()                              
{             
    int s, m;                                             //定义s,m
    for(s=1;s<=1000;s++)                                  //对于1~1000的数字逐个计算
    {
        m=pow(s,2);                                   //算出m的值,也就是将s平方
        if((m%10==s)||(m%100==s)||(m%1000==s))        //对于m各个位数上的数字的判断,即有任何一个位数等于s则满足条件
       {
            printf("%6d",s);                      //输出有六个空格间断的s
        }
    }
    return 0;                                             //返回主函数
}

1.2.2代码截图

1.2.3造测数据

数据 输出数据 说明
输出1~1000的所有同构数

1.2.3PTA说明
Q1: || 弄成%%了

2.代码互评

一,
ta

me

Q1:该同学用了嵌套语句用break跳出循环,而我只用了while语句
2.而且这同学用了两个if嵌在while里面,我只用了1个if,我的更为简洁明了。

3.学习总结

3.1学习进度条

这周所花时间 代码行 学到的知识点简介 目前比较迷惑的问题
第七周 19小时 286行 分支结构
第八周 15小时 338行 函数的定义和调用 暂无
第九周 18小时 422行 if-slse语句
第十周 20 小时 488行 switch
第十一周 20小时 520行 while和do-while结构 对有些语句结构还有些陌生

3.2累积代码行和博客字数

时间 代码行 博客字数
第七周 190 1050
第八周 250 1390
第九周 380 1670
第十周 450 1890
第十一周 600 2100

3.3学习内容总结和感悟

3.3.1学习内容总结
学习的函数类型很多,还需多多巩固,加强锻炼。提高质量。
2.保持一颗求学的心。持之以恒。让自己做到更好。
3.巩固do-while语句运用,continue语句,调用函数的运用
作业越来越难,但我们还是坚持下来。
凡是不能杀死我的都能使我更加强大。

Guess you like

Origin www.cnblogs.com/QQ709678842/p/11959830.html