版本1和2间的区别
于2006-03-12 15:45:24修订的的版本1
大小: 483
编辑: czk
备注:
于2006-03-12 15:48:42修订的的版本2
大小: 1015
编辑: czk
备注:
删除的内容标记成这样。 加入的内容标记成这样。
行号 7: 行号 7:
= 实验1 = = 实验2-1 =
行号 20: 行号 20:

= 实验2-2 =
 * strcrop(s, i, j) 取字符串s中第i个到第j个字符
 * strdel(s, i, j) 将字符串s中第i个到第j个字符删除
for example:
{{{#!cplusplus
char s[20]="hello world";
char t[20]="hello world";
strcrop(s, 1, 8);
strdel(t, 1, 8);
printf("%s\n%s\n", s, t);
}}}
output:
{{{
ello wor
hld
}}}

= 实验2-3 =
写一个函数weekday(y,m,d),求取y年m月d日是星期几,返回星期几的名字。例如:
{{{#!cplusplus
printf("%s", weekday(2006,3,6));
}}}输出
{{{Monday
}}}

实验要求

  • 实验前对实验内容做好预习
  • 有效利用实验时间,不做与实验无关的活动
  • 独立完成实验内容
  • 按时提交实验报告

实验2-1

1. 实验内容

写一个函数strinsert(s, n, t)在字符串s的第n个字符后面插入字符串t。比如:

   1 char s[100] = "write everywhere";
   2 char t[] = "once, run ";
   3 strinsert(s, 6, t);
   4 printf("%s", s); 

输出: {{{write once, run everywhere }}}

实验2-2

  • strcrop(s, i, j) 取字符串s中第i个到第j个字符
  • strdel(s, i, j) 将字符串s中第i个到第j个字符删除

for example:

   1 char s[20]="hello world";
   2 char t[20]="hello world";
   3 strcrop(s, 1, 8);
   4 strdel(t, 1, 8);
   5 printf("%s\n%s\n", s, t); 

output:

ello wor
hld 

实验2-3

写一个函数weekday(y,m,d),求取y年m月d日是星期几,返回星期几的名字。例如:

   1 printf("%s", weekday(2006,3,6));

输出

C语言课程实验 (2008-02-23 15:36:56由localhost编辑)

ch3n2k.com | Copyright (c) 2004-2020 czk.