苏嵌//许婷婷//2018.7.12

苏嵌                                                                                                                              项目实战

学习日志                                     姓名:许婷婷       日期:7.12

 

 

 

 

今日学习任务

 

1、辅导老师完成学习内容答疑;

23 小时完成 C 语言摸底测试;

扫描二维码关注公众号,回复: 3503356 查看本文章

今日任务完成情况

 

1、完成32条开发工具篇的题目,复习了之前学习的内容。

2、完成4C语言练习题。

 

 

 

今日开发中出现的问题汇总

 

对于指针指向字符串的使用不熟练

 

今日未解决问题

 

今日开发收获

复习回顾了这几天学习的内容,并且重新熟悉了C语言的相关内容,基本可以独立完成。

 

自我评价

 

 

经过一天的复习与练习,我对于老师几天讲授的内容更加清晰,并且我对C语言的编写更加熟练。

其他

 

 

 

杨辉三角形

  1#include <stdio.h>

  2

  3int main()

  4 {

 5     int n;

 6     int tr[100][100]={0};        //定义一个较大的数组

 7     int i;

 8     int j;

 9     printf("please enterthe number of lines of Yang hui trianghle:");

 10    scanf("%d",&n);            //

 11    for(i = 0;i < n;i ++ )      //逐行逐列的向数组输入数字

 12     {

 13        tr[i][0] = 1;           //输入杨挥三角形边框的一

 14        tr[i][i] = 1;

 15         for(j = 1;j < i;j ++)

 16        {

 17            tr[i][j] = tr[i - 1][j - 1] + tr[i - 1][j];   //计算每行不是1的数据

 18        }

 19     }

 20    for(i = 0;i < n;i ++)     //用循环输出数组

 21     {

 22        for(j = 0;j <= i;j ++)

 23        {

 24        printf("%6d",tr[i][j]);

 25        }

 26        printf("\n");

 27     }

 28    return 0;

 29 }

 

 

 

 

简易计算机

  1#include <stdio.h>

  2

  3int main()

  4 {

 5     int a;                  //定义输入的第一个数

 6     int b;                  //定义输入的第二个数

 7     char f;                 //定义运算符

 8     while(1)

 9     {

 10    scanf("%d",&a);        //输入第一个数

 11    scanf("%c",&f);        //输入运算符

 12    scanf("%d",&b);        //输入第二个数

 13    switch(f)               //判断运算符

 14     {

 15        case '+':printf("%d + %d = %d\n",a,b,a + b);break;   //加法运算,输出结果

 16        case '-':printf("%d - %d = %d\n",a,b,a - b);break;   //减法运算,输出结果

 17        case '*':printf("%d * %d = %d\n",a,b,a * b);break;   //乘法运算,输出结果

 18        case '/':printf("%d / %d = %d\n",a,b,a / b);break;   //除法运算,输出结果

 19        default:break;                                       //其他情况,跳出

 20     }

 21     }

 22    return 0;

 23 }

 

 

 

阶乘

  1#include <stdio.h>

  2

  3int main()

  4 {

 5     int n;

 6     int i;

 7     int sum = 1;          //定义结果为1

 8     printf("n = ");

 9    scanf("%d",&n);      //输入阶乘阶数

 10    for(i = n;i > 0;i --) //进行n次循环

 11     {

 12        sum = i * sum;    //循环依次减一与一相乘

 13     }

 14    printf("n! = %d",sum);//输出结果

 15    return 0;

 16 }

 

 

 

计算字符串中字串出现的次数

  1#include <stdio.h>

  2

  3main()

  4 {

 5     char string[40];                     //字符串

 6     char string1[10];                    //字串

 7     int i = 0;

 8     int j = 0;

 9     int count = 0;                       //次数

 10    scanf("%s",string);                  //输入字符串

 11    scanf("%s",string1);                 //输入字串

 12    while(string[i] != '\0')            //字符串没有扫描到结尾进行循环

 13     {

 14        while(string1[j] != '\0')       //字串没有扫描到结尾进行循环

 15        {

 16            if(string[i] == string1[j])  //字串与字符串相同时

 17            {

 18                 i ++;                    //比对下一个字符串

 19                 j ++;                    //比对下一个字串

 20                 if(string1[j] == '\0')   //下一个为'\0'

 21                 {

 22                     j = 0;               //字串从头开始

 23                     count ++;            //次数加一

 24                 }

 25            }

 26            else

 27            {

 28                 i ++;                    //不相同时字符串加一

 29                j = 0;                   //字串从0开始

 30                 break;

 31            }

 32         }

 33     }

 34    printf("次数为:%d\n",count);       //输出次数

 35    return 0;

 36 }

猜你喜欢

转载自blog.csdn.net/dada12138/article/details/81021911
今日推荐