学习日志1 姓名:周雪雯 日期:2018.9.10
今日学习任务:安装开发环境软件,熟悉软件的使用,用C语言编写程序并正确编译运行。
今日任务完成情况:完成老师上课所写的程序,编译成功运行出结果,完成老师布置的课后作业。
今日开发中出现的问题:C语言中的许多概念和知识点模糊不清,软件运用还是有点生疏,经常打错。
今日未解决问题:对结构体没有概念,C语言的指针运用不熟念,代码编写不流畅。
今日开发收获:学会开发环境软件的基本编程步骤,复习C语言内容。
自我评价:C语言与软件的使用都不足,以后加强练习。
作业
习题3:
#include<stdio.h>
#include<string.h>
int fun(char *a, char *b)
{
int len_b;
int count = 0;
int num = 0;
char *temp = b;
len_b = strlen(b);
while (*a != '\0')
{
if (*a == *temp)
{
while ((*a == *temp) && (*a != '\0') && (*temp != '\0'))
{
num++;
a++;
temp++;
}
if (num == len_b)
{
count++;
}
num = 0;
temp = b;
}
else
{
a++;
}
}
return count;
}
int main()
{
char a[100];
char b[10];
int num;
printf("Enter the main string(<=100)!\n");
scanf("%s",a);
printf("Enter the substring(<=10)!\n");
scanf("%s",b);
num = fun(a,b);
printf("The number is:%d\n",num);
return 0;
}
习题4:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void fun(char *s,char *t)
{
}
int main()
{
char str[] = "I am from Shanghai";
char *p1 = str;
char *p2 = str+strlen(str)-1;
char temp;
char *p3 = NULL;
while(p1<p2)
{
temp = *p1;
*(p1++) = *p2;
*(p2--) = temp;
}
puts(str);
p1 = str;
p2 = str;
while(*p2)
{
if(*p2 == ' ')
{
p3 = p2 - 1;
while(p1<p3)
{
temp = *p1;
*(p1++) = *p3;
*(p3--) = temp;
}
p1 = p2 + 1;
}
p2++;
}
p3 = p2-1;
while(p1<p3)
{
temp = *p1;
*(p1++) = *p3;
*(p3--) = temp;
}
printf("%s",str);
return 0;
}