
C
文章平均质量分 57
天空的颜色111
哈哈
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
文件读写操作
这个程序把一个文件中的数据有选择地复制到另一个文件中,它同时打开两个文件,程序通过只保留每三个字符的第三个来压缩文件内容,最后把压缩后的文本写入第二个文件中。#define _CRT_SECURE_NO_WARNINGS#include#include#includeint main(int argc ,char *argv[]){FILE *in, *out;in原创 2015-12-12 12:03:47 · 333 阅读 · 0 评论 -
输入三个整数,从小到大的顺序输出(利用指针)
#includeint main(){void fun(int *p1, int *p2, int *p3);int a, b, c;printf("enter three numbers :\n");scanf_s("%d%d%d", &a, &b, &c);fun( &a, &b, &c);return 0;}void fun(int *p1, int原创 2015-12-02 22:10:09 · 18559 阅读 · 1 评论 -
有N个整数,利用指针使前面各数顺序向后移M个位置
///////////////////有N个整数,使前面各数顺序向后移M个位置////////////////////#include#define N 10#define M 3int main(){void adjust(int *pt, int n, int m);int a[N];for (int i = 0; i scanf_s("%d", &a[i]原创 2015-12-03 22:39:52 · 3643 阅读 · 0 评论 -
利用指针对字符串排序
#include#includeint main(){void sort(char *pt[], int number);void print(char *pt[], int number);char str[3][20] = {0}; //这里的0不是数字0,而是字符0,代表的含义是'\0'(空字符);char *p[3]; //定义一个数组原创 2015-12-03 20:20:36 · 3367 阅读 · 2 评论 -
对于整数的处理(最小的与第一个交换,最大的与最后一个交换)
#includeint main(){void input(int *pt, int number);void print(int *pt, int number);void process(int *pt, int number);int a[10];int *p = a;int n = 5;printf("enter %d numbers:\n", n);原创 2015-12-03 22:04:28 · 524 阅读 · 0 评论 -
n个人围成一圈,顺序排号
/////n个人围成一圈,顺序排号,从第一个人开始报数,报到指定的数时推出圈子,问最后留下的是原来第几号的那位#include#define N 8#define M 3int main(){int a[N];for (int i = 0; i a[i] = i+1;int *p = a;int j = 0;//设置每次循环时计数变量,范围是0—N-1;原创 2015-12-04 11:48:41 · 631 阅读 · 0 评论 -
一个包含n个字符的字符串,从第m个字符开始复制成为另外一个字符串
/////一个包含n个字符的字符串,从第m个字符开始复制成为另外一个字符串//////////#include#includeint main(){void copystr(char *pt1, char *pt2, int number);char str1[20];char str2[20];printf("input string:\n");gets_s(原创 2015-12-04 17:40:12 · 2120 阅读 · 0 评论 -
分配内存空间
#include#include#Include>char *getstr();int main(){char *p=NULL;p = getstr();puts(p);free(p);return 0 ;}char *getstr(){char *str=NULL;str = (char * )malloc(sizeof(char)*5原创 2015-12-05 14:14:22 · 310 阅读 · 0 评论 -
统计大写,小写,数字等个数
#include#includeint main(){void statistics(char *pt);char str[100];int i = 0;while ((str[i] = getchar()) != '\n')i++;char *p = &str[0];statistics(p);return 0;}void statistics原创 2015-12-04 18:09:15 · 495 阅读 · 0 评论 -
void 指针类型例子
///////内存动态分配区和使用void 指针///////////////////程序中没有定义数组,而是开辟一段动态自由分配区,作为动态数组使用//调用malloc函数的返回值是 void * 型的,要先把它赋给P1,进行类型转换//把该指针转换成 int * 型;#include#include //程序中含有malloc函数,应包含stdlib.hint m原创 2015-12-02 20:22:18 · 546 阅读 · 0 评论 -
利用返回指针值的函数进行查找学生的成绩
#includeint main(){int *search(int(*pointer)[4], int number);int *p;int k;int score[][4] = { { 45, 85, 78, 89 }, { 78, 89, 88, 99 }, { 78, 89, 89, 50 }, { 60, 85, 95, 20 } };printf("ente原创 2015-11-30 15:18:21 · 442 阅读 · 0 评论 -
枚举类型简单例子
//枚举类型例子#includeint main(){enum Color {red ,yellow,blue,white,black };//声明枚举类型enum Colorint i, j, k, pri;//定义枚举变量int n, loop;n = 0;for (i = red; i for (j = red; j if (i != j)//如果两原创 2015-12-17 19:00:02 · 3172 阅读 · 0 评论 -
若干个字符串排序,然后写到文件中
#define_CRT_SECURE_NO_WARNINGS#include#include#include#define LINE 3int main(){ charstr[LINE][10]={0}; inti = 0 ; chartemp[10] = {0} ; intm = 0 , n原创 2015-12-13 21:25:26 · 1407 阅读 · 0 评论 -
文件与结构体
#define _CRT_SECURE_NO_WARNINGS#include#define LEN 3struct Student{int num;char name[20];int age;char addr[15];}stu[LEN]; //定义全局结构体数组;void save(struct Student stud[]){FILE原创 2015-12-28 17:06:00 · 618 阅读 · 0 评论 -
结构体例题汇总
例一://///结构体变量初始化和引用#includeint main(){ structStudent { longintnum; charname[20]; charsex; char原创 2015-12-16 21:29:02 · 3957 阅读 · 0 评论 -
指向指针数据的指针变量
#includeint main(){char *name[] = { "follow me", "basic", "great wall", "fortran", "computer design" };//定义一个指针数组;char **p;//p是指向char*型数据的指针变量,即指向指针的指针;int i;for (i = 0; i {p = nam原创 2015-11-30 20:28:43 · 668 阅读 · 1 评论 -
指向指针的指针(2)
////////////指针数组的元素指向整型数组的元素///////////#includeint main(){int a[5] = { 1, 2, 3, 4, 5 };int *name[5] = { &a[0], &a[1], &a[2], &a[3], &a[4] };int **p;p = name;for (int i = 0; i {prin原创 2015-11-30 20:50:30 · 304 阅读 · 0 评论 -
利用指针找出不及格学生的成绩
#includeint main(){int *search(int (*pointer)[4]);int *p;int score[4][4] = { { 60, 85, 78, 89 }, {59, 89, 88, 99 }, { 78, 89, 89, 50 }, { 60, 85, 95, 20 } };int i, j;for (i = 0; i {p原创 2015-11-30 15:38:29 · 1526 阅读 · 0 评论 -
利用指针数组实现将若干字符串按照字母顺序输出
/////////利用指针数组实现将若干字符串按照字母顺序输出///////////#include#includeint main(){void sort( char *name[], int n);void print(char *name[], int n);char *name[5] = { "follow me", "basic", "great wall",原创 2015-11-30 16:31:49 · 2560 阅读 · 0 评论 -
共用体简单例子
//共用体例子#define _CRT_SECURE_NO_WARNINGS#include//声明无名的结构体类型struct{int num;//成员编号char name[20];//成员姓名char sex;//成员性别char job;//成员职业union //声明无名的共用体类型{int clas;//成员班级char pos原创 2015-12-17 11:13:17 · 1260 阅读 · 0 评论 -
the length of the string
#includeint length(char *pt);int main(){char a[100];char *p=a;printf("input string:");gets_s(a);int l;l=length(p);printf("the length of the string is %d\n", l);return 0;}int原创 2015-12-04 16:57:54 · 952 阅读 · 0 评论