摘要: /* 有n个正数,使得前面每个数依次后移m个位置,最后m个数变成最前面m个数 */ #include <stdio.h> #include <stdlib.h> #define N 10 void reverse(int a[],int left,int right) { int i,j,temp; 阅读全文
posted @ 2021-09-22 21:29 叶梓渔 阅读(52) 评论(0) 推荐(0)
摘要: /* 输入年月日,判断这一天是该年的第几天。 */ #include <stdio.h> #include <stdlib.h> typedef struct Data { int year; int month; int day; }Data; int calculate(Data data) { 阅读全文
posted @ 2021-09-22 21:28 叶梓渔 阅读(570) 评论(0) 推荐(0)
摘要: /* 求一个字符串的长度 */ #include <stdio.h> #include <stdlib.h> int strLen(char *pStr) { char *p = pStr; int Length = 0; while(*p != '\0') { ++ p; ++ Length; } 阅读全文
posted @ 2021-09-22 21:27 叶梓渔 阅读(148) 评论(0) 推荐(0)
摘要: /* 设计一个函数process,在你调用他的时候,每次实现不同的功能,输入a,b两个数, 第一次调用时找出a,b中的最大者。 第二次找出最小者,,第三次求两个数的和。 */ #include <stdio.h> #include <stdlib.h> int process(int a,int b 阅读全文
posted @ 2021-09-22 21:23 叶梓渔 阅读(122) 评论(0) 推荐(0)
摘要: /* 求Sn = a + aa + aaa + aaaa + ....其中a为一个数字,一共有n项。a和n由用户键盘输入。 */ #include <stdio.h> #include <stdlib.h> void anFunc() { int Sn =0,p = 0; int a,n; prin 阅读全文
posted @ 2021-09-22 21:22 叶梓渔 阅读(305) 评论(0) 推荐(0)
摘要: /* 编写一个函数,试输入一个字符串安反序存放。 */ #include <stdio.h> #include <stdlib.h> void reverse(char *pStr) { int strLength = 0; char *front = pStr; while(*front != ' 阅读全文
posted @ 2021-09-22 21:20 叶梓渔 阅读(420) 评论(0) 推荐(0)
摘要: /* 数组a和b各有10个元素。将他们相同的位置元素逐个比较, 如果a中元素大于b中对应元素的次数多于b数组中元素大于a中元素的次数, 则认为a大于b。请统计大于等于小于的次数 */ #include <stdio.h> #include <stdlib.h> void compare(int ar 阅读全文
posted @ 2021-09-22 21:18 叶梓渔 阅读(367) 评论(0) 推荐(0)
摘要: /* 用时间最短的方法将负数全部排在正数前面。比如:-4 -6 -3 -2 -1 0 0 4 3 2 */ #include <stdio.h> #include <stdlib.h> void negativeBeforePostive(int arra[],int arraLength) { i 阅读全文
posted @ 2021-09-22 21:16 叶梓渔 阅读(203) 评论(0) 推荐(0)
摘要: /* 将两个字符串s1,s2进行比较,如果s1>s2,则输出一个正数。如果s1 = s2,输出零。如果s1 < s2, 输出一个负数,不用strcmp函数,输出的正数或者负数的绝对值应该是比较两字符串相应字符的ascii码的差值。 */ #include <stdio.h> #include <st 阅读全文
posted @ 2021-09-22 21:15 叶梓渔 阅读(559) 评论(0) 推荐(0)
摘要: /* 将字符串数组s2中全部字符复制到字符数组s1中,不用strcpy函数 */ #include <stdio.h> #include <stdlib.h> void strCpy(char *pStr1,char *pStr2) { while(*pStr2 != '\0') { *pStr1 阅读全文
posted @ 2021-09-22 21:14 叶梓渔 阅读(996) 评论(0) 推荐(0)