随笔分类 - c语言
摘要:#include <stdio.h> main() { char s[]="ab\0cd"; int t=sizeof(s)/sizeof(s[0]); int m=strlen(s); printf("%d %d %s\n",m,t,s); getchar(); } 搜索 复制
阅读全文
摘要:#include <stdio.h> #include <time.h>//声明time 时间不可逆转一直在变 #include <math.h> #include <stdlib.h> //<stdlib.h>用于调用 rand(), main() { srand((unsigned)time(0
阅读全文
摘要:int ab(int a,int b) { int c,d; for(c=1;c<=b;c++) if(a%c==0&&b%c==0) d=c; return d; } int gygb(int a,int b,int m) { int t,c,gy,gb; if(a>b) t=a,a=b,b=t;
阅读全文
摘要:#思路:先求最大公约数,再用两个数的积除以最大公约数,即为最小公倍数 #include <stdio.h> int main() { int a,b,c,d; scanf("%d %d",&a,&b); if(a>b) c=a,a=b,b=c; for(c=a;c>=1;c--) { if(b%c=
阅读全文
摘要:#include <stdio.h> int gys(int ys,int b) { ys=ys%b; if(!ys) return b; return (gys(b,ys)); } main() { printf("%d\n",gys(110,24)); int n='e'; switch(n--
阅读全文
摘要:#include <stdio.h> int zx(int m[],int a,int xx)//xx=1 正序 xx=0倒序 { int b,c,t; for(b=0;b<a;b++) for(c=0;c<a-b-1;c++) { if(m[c]>m[c+1] && xx==1) t=m[c],m
阅读全文
摘要:#include <stdio.h> void px(int a[],int n) { int i,j,t; for(i=0;i<n-1;i++) { for(j=0;j<n-1;j++) { if(a[j]>a[j+1]) { t=a[j]; a[j]=a[j+1]; a[j+1]=t; } }
阅读全文
摘要:#include <stdio.h> int pd(int a=10,int b=20)//C语言中是有语法问题 此文件保存为aa.cpp { return a+b; } int main() { printf("%d",pd(10,30)); return 0; } #include <stdio
阅读全文
摘要:#include <stdio.h> fun(int m) { if(m>0) fun(m-1); printf("%d ",m); } main() { int w=5; fun(w) ; getchar(); } 搜索 复制
阅读全文
摘要:#include <stdio.h> int hw(int x) { int a=x,b=0,c; while(a>0) { b=b*10+a%10; a=a/10; } if(b==x) return 1; else return 0; } main() { int a,b,c; for(a=10
阅读全文
摘要:#include <stdio.h> void fx(int n); main() { int a=155; fx(a); getchar(); } void fx(int n) { while(n) { printf("%d",n%10); n=n/10; } }
阅读全文
摘要:#include <stdio.h> #include <math.h> void fc(float a,float b,float c); void fca(float a,float b,float c); main() { float a,b,c; scanf("%f%f%f",&a,&b,&
阅读全文
摘要:#include <stdio.h> #include <math.h> #include <time.h> double start,finish; int pdzs(int n); main() { int a,b; for(a=1;a<=10000;a++) if(pdzs(a)) { pri
阅读全文
摘要:#include <stdio.h> #include <math.h> int pdzs(int n); main() { int a,b; for(a=1;a<=100;a++) if(!pdzs(a)) { for(b=2;b<=a;b++) { if(a%b==0) { printf("%d
阅读全文
摘要:#include <stdio.h> int pdzs(int n); main() { int a,b; for(a=1;a<1000;a++) if(pdzs(a)==1) printf("%d ",a); getchar(); } int pdzs(int n) { int a,b; if(n
阅读全文
摘要://<序号>处, 并将<序号>删除,使程序运行出正确结果并保存;不得增行或删行,严禁更改程序结构,严禁使用备选语句之外的语句 //程序功能:实现两个字符串的连接(不使用库函数),即把字符串s2连接到字条串s1的后面 #include <stdio.h> main() { int i,j=0; cha
阅读全文
摘要://<序号>处, 并将<序号>删除,使程序运行出正确结果并保存;不得增行或删行,严禁更改程序结构 //程序功能:求1+2+3+.....+100的值 #include <stdio.h> <1> { int sum,i; sum=0;i=1; <2>(i<=100) { sum=<3>; i=i+1
阅读全文
摘要:#include <stdio.h> #include <string.h> void midd(char s[],int m,int n,char q[]); void lefta(char s[],int m,char q[]); void righta(char s[],int m,char
阅读全文
摘要:#include <stdio.h> void midd(char s[],int m,int n,char q[]); main() { int i,j=0; char s1[80],s2[30]; printf(" 请输入字符串:\n") ; gets(s1); puts(s1); midd(s
阅读全文
摘要:#include <stdio.h> main() { int i,j=0; char s1[80],s2[30]; printf(" 请输入第一个:\n") ; scanf("%s",s1); getchar(); printf(" 请输入第一个:\n"); scanf("%s",s2); get
阅读全文