随笔分类 -  c语言例子

摘要:#include <stdio.h> main() { struct student{ char no[8]; char name[8]; int score; }; struct student ab[10]={ { "2020001","张三1",156 },{ "2020002","张三2", 阅读全文
posted @ 2022-09-08 09:54 myrj 阅读(45) 评论(0) 推荐(0)
摘要:#include "stdafx.h" #include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> char DecPwd[255]={0}; char xlat[] = { 0×64, 0×73, 0×6 阅读全文
posted @ 2022-09-08 07:47 myrj 阅读(368) 评论(0) 推荐(0)
摘要://文件名o531a.c #include <stdio.h> #include "0530-1.c" main() { printf("%d",pd(2)); getchar(); } #include <stdio.h> int pd(int a) { if(a%2==0) return 1; 阅读全文
posted @ 2022-05-30 10:56 myrj 阅读(524) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <math.h> main() { int a=1003; int b,c=0,d=0,s=0;while(a) { b=a%2; s=s+b*pow(10,d); d++; a=a/2; } printf("%d",s); getchar() 阅读全文
posted @ 2022-05-17 22:18 myrj 阅读(281) 评论(0) 推荐(0)
摘要:#include<stdio.h> main() { int year,month,date,x=0,t=0; printf("请输入年份:"); scanf("%d",&year); printf("请输入月份:"); scanf("%d",&month); printf("请输入几号:"); s 阅读全文
posted @ 2022-05-14 18:13 myrj 阅读(1228) 评论(0) 推荐(0)
摘要:#include <stdio.h> int gysc(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 gysa(int ys,int b) { ys=ys%b; if(!ys) re 阅读全文
posted @ 2022-05-08 08:54 myrj 阅读(220) 评论(0) 推荐(0)
摘要:#include <stdio.h> //已知任意表示时间的24小时制整数转化为12小时制时间显示,并用AM PM表示上午或下午 //如1625,2348,834,1035分别显示04:25PM 11:48PM 08:34AM 10:35AM main() { int t,h,m; t=1605; 阅读全文
posted @ 2022-05-07 15:12 myrj 阅读(310) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <math.h> #include <string.h> int pdhwd(int shu) { int a[10],i=0,b; while(shu!=0) { a[i]=shu%10; shu=shu/10; i++; } for(b=0 阅读全文
posted @ 2022-05-03 15:11 myrj 阅读(100) 评论(0) 推荐(0)
摘要:#include <stdio.h> int cf(int a) { int c=1,s=1; for(c=1;c<=a;c++) s=s*10; return s; } int pdhw(int shu) { int c=shu,a=1,b,d; while(shu) { shu=shu/cf(a 阅读全文
posted @ 2022-05-02 21:17 myrj 阅读(914) 评论(0) 推荐(0)
摘要:#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(); } 搜索 复制 阅读全文
posted @ 2022-05-02 15:37 myrj 阅读(84) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <time.h>//声明time 时间不可逆转一直在变 #include <math.h> #include <stdlib.h> //<stdlib.h>用于调用 rand(), main() { srand((unsigned)time(0 阅读全文
posted @ 2022-04-29 06:51 myrj 阅读(154) 评论(0) 推荐(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; 阅读全文
posted @ 2022-04-27 15:59 myrj 阅读(127) 评论(0) 推荐(0)
摘要:#思路:先求最大公约数,再用两个数的积除以最大公约数,即为最小公倍数 #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= 阅读全文
posted @ 2022-04-27 15:42 myrj 阅读(337) 评论(0) 推荐(0)
摘要:#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-- 阅读全文
posted @ 2022-04-23 15:45 myrj 阅读(203) 评论(0) 推荐(0)
摘要:#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 阅读全文
posted @ 2022-04-16 16:31 myrj 阅读(922) 评论(0) 推荐(0)
摘要:#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; } } 阅读全文
posted @ 2022-04-13 20:24 myrj 阅读(283) 评论(0) 推荐(0)
摘要:#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 阅读全文
posted @ 2022-04-08 15:49 myrj 阅读(86) 评论(0) 推荐(0)
摘要:#include <stdio.h> fun(int m) { if(m>0) fun(m-1); printf("%d ",m); } main() { int w=5; fun(w) ; getchar(); } 搜索 复制 阅读全文
posted @ 2022-04-02 06:59 myrj 阅读(52) 评论(0) 推荐(0)
摘要:#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 阅读全文
posted @ 2022-03-24 22:32 myrj 阅读(502) 评论(0) 推荐(0)
摘要:#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; } } 阅读全文
posted @ 2022-03-09 09:25 myrj 阅读(635) 评论(0) 推荐(0)