摘要: //下面函数检查给定的字符串s是否满足下列两个条件: //1. 字符串s中左括号"("的个数与右括号")"的个数相同。 //2. 从字符串首字符起顺序检查 s 中的字符的过程中,遇到的右括号")"的个数在任何时候均不超过所遇到的左括号"("数。 //若字符串同时满足上述条件,则函数返回非0 值,否则 阅读全文
posted @ 2020-11-01 23:23 yanglike111 阅读(795) 评论(0) 推荐(0) 编辑
摘要: //给定程序,函数fun的功能是:将自然数1-10以及它们的平方根写到名为myfile3.txt的文本文件中, //然后再顺序读出显示在屏幕上。 #include <stdio.h> #include<math.h> //包含数学头文件 int fun(char *fname) { FILE *fp 阅读全文
posted @ 2020-11-01 22:55 yanglike111 阅读(1226) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> int main() { unsigned int a=6; int b=-20; (a+b>6)?puts("sum>6"):puts("sum<=6"); }//运行结果: sum>6 #include <stdio.h> int main() { int 阅读全文
posted @ 2020-09-23 14:45 yanglike111 阅读(217) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> int main() { char s1[]="I love China"; char s2[]="I love"; char *str1=s1,*str2=s2; int answer=0; while(!(answer=*str1-*str2)&& *str 阅读全文
posted @ 2020-09-23 14:25 yanglike111 阅读(142) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> int main() { int a[]={89,88,76,70,68,58}; int x=70,mid,pos=-1,find=0,low=0,high=5; while(!find && low<=high){ mid=(low+high)/2; if( 阅读全文
posted @ 2020-09-23 14:13 yanglike111 阅读(158) 评论(0) 推荐(0) 编辑
摘要: //下面程序的功能是把一个文件的内容拷贝到另一个文件,如果拷贝成功,则提示 //"File Copy Success!"。 #include <stdio.h> int main() { FILE *fpSrc;//源文件 FILE *fpDes;//目标文件 int ch; if((fpSrc=f 阅读全文
posted @ 2020-09-23 10:54 yanglike111 阅读(235) 评论(0) 推荐(0) 编辑
摘要: //下列给定程序中函数f的功能是:根据整型形参(x,t),计算公式前几项的值。 //例如,若x=2,n=10,则输出为:sin(2)=0.909347 #include <stdio.h> double f(int x,int n) { int i,j; long double t,xt; int 阅读全文
posted @ 2020-09-23 10:40 yanglike111 阅读(134) 评论(0) 推荐(0) 编辑
摘要: /*下面程序的功能是:调用Sort()排序函数,通过传递相应参数用选择法按升序(或降序) 对数组中的数进行排序。假设数组中存储数据为{88,67,78,56,90},若升序排序则结果为: {56,67,78,88,90},若降序排序则结果为 {90,88,78,67,56}。 */ #include 阅读全文
posted @ 2020-09-23 09:06 yanglike111 阅读(189) 评论(0) 推荐(0) 编辑
摘要: //2020年湖南对口计算机35题。下面程序中定义了三个函数,其功能分别是添加链表结点,显示链表结点与删除链表结点。 //如果添加的链表结点数据为“11,22,33,44,55”,则显示链表为“11->22->33->44->55->End”。如果删除数据为33的结点, //则显示链表为 “11-> 阅读全文
posted @ 2020-09-22 14:30 yanglike111 阅读(174) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> int main() { char str[]="hello world"; char *p=str; *(p+5)=0; printf("str=%s\n",str); return 0; } 运行结果:str=hello #include <stdio.h> 阅读全文
posted @ 2020-07-17 09:56 yanglike111 阅读(131) 评论(0) 推荐(0) 编辑