摘要:/*编写函数replace(char *s,char c1,char c2)实现将s所指向的字符串中所有字符c1用c2替换,字符串、字符c1和c2均在主函数中输入,将原始字符串和替换后的字符串显示在屏幕上*/ #include <stdio.h> void replace(char *s,char
阅读全文
摘要:/*已知数组a中的元素已按由小到大顺序排列,以下程序的功能是将输入的一个数插入数组a中,插入后,数组a中的元素仍然由小到大顺序排列*/ #include <stdio.h> /** * 折半查找法找到需要插入的位置(下标) * * @param p 数组 * @param num 需要插入的数 *
阅读全文
摘要:/*编写一个void sort(int *x,int n)实现将x数组中的n个数据从大到小 排序。n及数组元素在主函数中输入。*/ #include <stdio.h> void sort(int *x, int n); void outPutAraay(int *x, int n); void s
阅读全文
摘要:/*完善程序,实现将输入的字符串反序输出,如输入windows 输出swodniw。*/ #include <stdio.h> #include <string.h> int main(int argc, const char * argv[]) { printf("请输入一段字符串,以回车结束\n
阅读全文
摘要:/*通过键盘输入3名学生4门课程的成绩,分别求每个学生的平均成绩和每门课程的平均成绩。要求所有成绩均放入一个4行5列的数组中,输入时同一人数据间用空格,不同人用回车 其中最后一列和最后一行分别放每个学生的平均成绩、每门课程的平均成绩及班级总平均分。*/ #include <stdio.h> int
阅读全文
摘要:/*实现程序的功能:从字符数组s中删除存放在c中的字符。*/ #include <stdio.h> int main(int argc, const char *argv[]) { char s[80],c; printf("请输入一个字符串\n"); gets(s); printf("请输入一个字
阅读全文
摘要:/*编程打印直角杨辉三角形 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 */ #include <stdio.h> int main(int argc, const char * argv[]) { int a[6][6] = {0}; for (int
阅读全文
摘要:/*将一个4×4的数组进行逆时针旋转90度后输出,要求原始数组的数据随机输入,新数组以4行4列的方式输出,请在空白处完善程序。*/ #include <stdio.h> int main(int argc, const char * argv[]) { int a[4][4],b[4][4],i,j
阅读全文
摘要:/*一个数如果恰好等于它的因子之和,这个数就称为“完数”。例如6=1+2+3.编程找出1000以内的所有完数。*/ #include <stdio.h> int main(int argc, const char * argv[]) { for (int i = 2; i < 1000; i++)
阅读全文
摘要:/*古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少?兔子的规律为数列1,1,2,3,5,8,13,21....*/ #include <stdio.h> //f(n) = 2f(n-1) - (f(n-1)
阅读全文
摘要:/*判断101-200之间有多少个素数,并输出所有素数及素数的个数。程序分析:判断素数的方法:用一个数分别去除2到sqrt(这个数),如果能被整除,则表明此数不是素数,反之是素数。*/ #include <stdio.h> int main(int argc, const char * argv[]
阅读全文
摘要:要求:/*输出9*9口诀。共9行9列,i控制行,j控制列。*/ #include <stdio.h> int main(int argc, const char * argv[]) { for (int i = 1; i <= 9; i++) { for (int j = 1; j <= i; j+
阅读全文