December 2006
Saturday, 30. December 2006, 13:05:12
随手记(Conveniently Log)
别人都说新年将至而我却在这说旧年将去。是因为我认为这将逝去有一年没干什么吧!今天晚上考试的。考的C语言,全是编程题还是笔试。各种方法都用了,又是自定义函数又是指针,卷面搞的好乱。到处都是改动的箭头,我想助教看到了一定头痛。还有可能给个评语“卷面野指针太多”。
Saturday, 30. December 2006, 12:41:53
C&C++
/*一、有一字符串,包含n个字符。写一函数,将此字符串从第m个字符开始的全部字符复制成为另一个字符串。*/
#include <stdio.h>
#define N 10
void str_copy (char *str,char *str_cp,int m);
main ()
{
int n,i;
char A[N],B[N];
gets(A);
printf ("where copy to n:");
scanf ("%d",&n);
while (n <0||n>=N)
{
printf ("n beyond!");
scanf ("%d",&n);
}
str_copy (A,B,n);
i=0;
while (B!='\0')
{
printf ("%c",B);
i++;
}
printf ("\n");
}
void str_copy (char *str,char *str_cp,int m)
{
char *p,*q;
p=&str[m];
q=str_cp;
while (*p!='\0')
{
*q=*p;
p++;
q++;
}
*q=*p;
}
Tuesday, 26. December 2006, 12:03:55
C&C++
这个程序在我的TC下与G++下编译后运行结果正确,可是用GCC编译运行了就是不对!不解!!!!
Read more...
Tuesday, 26. December 2006, 11:15:21
C&C++
/*1.实现函数strcmp()的功能,即比较两字符串的大小。*/
int strcmp (char str1[],char str2[])
{
//char s1,s2;
unsigned int i,j,m;
i=j=m=n=0 ;
/*while (1)
{
if (str1!='\0')
i++;
else
break;
}
while (1)
{
if (str2[j]!='\0')
j++;
else
break;
}
*/
while (str1==str2[j])
{
i++ ;
j++;
m++;
}
if (str1>str2[j])
return 1;
if (str1<str2[j])
return -1;
else
return 0;
}
Friday, 22. December 2006, 04:52:37
随手记(Conveniently Log)
梦想着再次回到学校,这回还真的回到学校学习了。还不是一般的学校。要好好的利用学校的资源!好的学校就是不一样!