会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
Andy Cheung
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
5
6
7
8
9
10
11
下一页
2013年10月25日
对单向链表的综合操作
摘要: 1 #include 2 #include 3 #include 4 5 #define LEN sizeof(struct student) 6 7 struct student{ 8 long num; 9 float score; 10 stru...
阅读全文
posted @ 2013-10-25 17:02 Andy Cheung
阅读(288)
评论(0)
推荐(0)
2013年10月23日
单向链表操作:新建,输出,删除,插入
摘要: 1.新建算法:使p1指向新开辟的结点,p2指向链表中最后一个结点,把p1所指的结点连接在p2所指结点的后面,用“p2->next=p1”来实现。 1 #include 2 #include 3 #include 4 5 #define LEN sizeof(struct student) 6 7...
阅读全文
posted @ 2013-10-23 16:49 Andy Cheung
阅读(471)
评论(1)
推荐(0)
2013年10月22日
用fscanf()从文件取数据时,如何判断文件结束
摘要: 例子:从键盘输入若干行字符(每行长度不等),输入后把它们存储到一磁盘文件中。再从该文件中读入这些数据,将其中小写字母转换成大写字母后再显示屏上输出。有两种方法1.使用feof()函数 1 #include 2 #include 3 #include 4 5 int main(){ 6 se...
阅读全文
posted @ 2013-10-22 10:23 Andy Cheung
阅读(4036)
评论(0)
推荐(0)
2013年10月21日
使用fwrite()函数和fprintf()函数输出数据到文件时的区别
摘要: 使用书上的一个课后题为例有5个学生,每个学生有3门课的成绩,从键盘输入学生数据(包括学号,姓名,3们课程成绩),计算出每个学生的平均成绩,将原有数据和计算出的平均分数存放在磁盘文件“stud”中。屡次调试后,我编好的程序: 1 #include 2 #include 3 #define FWRITE...
阅读全文
posted @ 2013-10-21 10:54 Andy Cheung
阅读(3211)
评论(3)
推荐(0)
2013年10月20日
使用feof()函数判断文件是否结束
摘要: 课本上时这样写的:(用putchar(ch);代表对取出来的字符的处理。)1 while(!feof(fp))2 {3 ch=fgetc(fp);4 putchar(ch);5 }但是,这样写的话,fgetc()函数总是会多读入一个字符。应该改为如下形式:1 ch=fgetc(fp)...
阅读全文
posted @ 2013-10-20 21:24 Andy Cheung
阅读(2043)
评论(2)
推荐(0)
2013年10月18日
编写一函数用来实现左右循环移位。函数原型为move(value,n);n>0时右移n位,n<0时左移|n|位。
摘要: 1 #include 2 #include 3 4 int main(){ 5 setbuf(stdout,NULL); 6 int move(int,int); 7 int value,n; 8 int result; 9 10 printf("Input the value:\n");11 scanf("%x",&value);12 13 printf("How to move?\n");14 scanf("%d",&n);15 16 result=move(value,n);17 printf
阅读全文
posted @ 2013-10-18 21:41 Andy Cheung
阅读(1655)
评论(0)
推荐(0)
编写一个函数,对一个16位的二进制数取出它的奇数位(即从左边起,第1,3,5,...,15位)。
摘要: 1.先贴我的代码,VC6.0开发环境下去掉第5行。 1 #include 2 #include 3 4 int main(){ 5 setvbuf(stdout,NULL,_IONBF,0); 6 int value; 7 int getodds(int value); 8 9 printf("Input the value:");10 scanf("%o",&value);11 12 printf("The result is %o.",getodds(value));13 14 return EXIT_SUCCESS;15
阅读全文
posted @ 2013-10-18 17:35 Andy Cheung
阅读(5562)
评论(0)
推荐(0)
2013年10月16日
写一个函数,实现两个字符串的比较。即实现strcmp函数,s1=s2时返回0,s1!=s2时返回二者第一个不同字符的ASCII值。
摘要: 1 #include 2 #include 3 4 int main(){ 5 setvbuf(stdout,NULL,_IONBF,0); 6 char s1[255],s2[255]; 7 int strcmp(char *,char *); 8 int result; 9 10 printf("1st string:");11 gets(s1);12 printf("2nd string:");13 gets(s2);14 result=strcmp(s1,s2);15 printf("The compa...
阅读全文
posted @ 2013-10-16 11:21 Andy Cheung
阅读(3871)
评论(0)
推荐(0)
输入一个字符串,内有数字和非数字字符,将其中连续的数字作为一个整数,依次存放到一数组a中。统计共有多少个整数,并输出这些数。
摘要: #include#include#include#includeint main(){ setvbuf(stdout,NULL,_IONBF,0); char s[255]; int a[255]; //存放得到的整数 int i,length; ...
阅读全文
posted @ 2013-10-16 09:41 Andy Cheung
阅读(7367)
评论(0)
推荐(0)
2013年10月14日
将一个5*5的矩阵中最大的元素放在中心,4个角分别放4个最小的元素(顺序为从左到右,从上到下顺序依次从小到大存放),写一函数实现之。
摘要: #include#includeint main(){ setvbuf(stdout,NULL,_IONBF,0); int a[5][5]; int i,j; void process(int *a); printf("Input the matrix:\n"); for(i=0;ia[max]) max=i; if(max!=12) { t=a[max]; a[max]=a[12]; a[12]=t; } //寻找4个小数,放四角 for(i=0;i<4;i++...
阅读全文
posted @ 2013-10-14 16:35 Andy Cheung
阅读(3205)
评论(0)
推荐(0)
上一页
1
···
5
6
7
8
9
10
11
下一页
公告