随笔分类 - c语言
摘要:#include "stdio.h" void main() { int i; //任意10个数值,也可以不是8位 unsigned char data[10]={0x12,0x21,0x1A,0xB1,0xC1,0xEB,0xDF,0xCA,0xF6,0xDD}; unsigned char ou
阅读全文
摘要:#include <stdio.h> int shu(int a,int b); main() { printf("%d",shu(23,56)); getchar(); } int shu(int a,int b) { int aa; aa=(b%10)*1000+b/10*100+(a%10)*
阅读全文
摘要:同构数:一个数是其平方的尾数:如5 25 ;25 625; #include <stdio.h> main() { int a,b,c; for(a=1;a<10000;a++) if(tgs(a)) printf("%d ",a); getchar(); } int tgs(int x) { in
阅读全文
摘要:int m=sizeof(bc)/sizeof(bc[0]),d ; printf("%d ",m) ;
阅读全文
摘要:#include <stdio.h> main() { int a; scanf("%d",&a); printf("%d",hea(a)); getchar(); } int hea(int a) { int b,gs=0; for(b=1;b<=a;b++) if(b%3==0 && b%10=
阅读全文
摘要:#include <stdio.h> int bh(int s,int a) { while(s) { if(s%10==a) return 1; s=s/10; } return 0; } main() { int sum=0,a,b,c; for(a=1;a<=1000;a++) if(bh(a
阅读全文
摘要://一只小猴子一天摘了许多桃子,第一天吃了一半,然后忍不住又吃了一个;第二天又吃了一半,再加上一个; //后面每天都是这样吃。到第10天的时候,小猴子发现只有一个桃子了。问小猴子第一天共摘了多少个桃子。 #include<stdio.h> int main() { int i = 1; int j
阅读全文
摘要:#include <stdio.h> int main() { int arr[] = { 22, 34, 3, 32, 33,22,33,33,22,82, 55, 89, 50, 37, 5, 64, 35, 9, 70 }; int len = (int) sizeof(arr) / size
阅读全文
摘要:#include <stdio.h> int main() { int arr[] = { 22, 34, 3, 32, 82, 55, 89, 50, 37, 5, 64, 35, 9, 70 }; int len = (int) sizeof(arr) / sizeof(*arr); print
阅读全文
摘要:#include <stdio.h> #define N 10 main() { int shu[N][N]={0},a,b,c; for(a=0;a<N;a++) { for(c=N-1-a;c>=0;c=c-1) printf(" ") ; for(b=0;b<=a;b++) { shu[a][
阅读全文
摘要:#include <stdio.h> #include <math.h> main() { int shu[6][6]={0}; int a,b; for(a=0;a<6;a++) { for(b=0;b<6;b++) { if(a==b) shu[a][b]=1; if(a+b==5) shu[a
阅读全文
摘要:#include <stdio.h> #include <string.h> int main(){ char cs[1024]; gets(cs); int count[256] = {0},i,m; for(i=0; i<strlen(cs); i++) count[cs[i]]++; int
阅读全文
摘要:#include <stdio.h> main() { float shu[3][5],sum1[3]={0},sum2[5]={0},pjf1[3],pjf2[5]; int a,b; for(a=0;a<3;a++) { for(b=0;b<5;b++) { scanf("%f",&shu[a]
阅读全文
摘要:编程:1.用两个循环为整型数组赋值,结果如下 shu[3][4]={{1,2,3,4},{5,6,7,8},{9,10,11,12}} 2.用两个循环为整型数组赋值,结果如下 shu[3][4]={{1,2,3,4},{5,6,7,8},{0,0,0,0}} 3.用两个循环为整型数组赋值,结果如下
阅读全文
摘要:#include<stdio.h>//头文件 int main()//主函数 { int number,i;//定义变量 printf("请随机输入一个数:");//提示语句 scanf("%d",&number);//键盘输入需要判断的数 for(i=2;i<=number-1;i++)//循环从
阅读全文
摘要:#include <stdio.h> //s=1-3+5-7+....-99+101 main() { int i,t=1,s=0; for(i=1;i<=101;i+=2) { t=t*i; s=s+t; t=-t/i; } printf("%d\n",s); getchar(); } #incl
阅读全文
摘要:#include<stdio.h> //当前程序运行时如果输入*回车,则一直显示需要补考,不停止 //原因:scanf()键盘输入,有一个缓冲区,遇到回车才结束 //*指针,对应scanf()中涉及到的变量 //保留scanf()后面的getchar(),则“吸收”了回车,只有*,整型为0,所以才显
阅读全文
摘要:#include <stdio.h> main() { int shu,ge=0,shi=0,bai=0,qian=0; scanf("%d",&shu); if(shu<=0 || shu>=10000) printf("输入错误"); else { if(shu>=1 && shu<=9) ge
阅读全文
摘要://选择排序#include <stdio.h> main() { int a[10]={1,3,99,1,4,7,2,3,1,6},i,j,k,t,b; for(i=0;i<=9;i++) { k=i; for(j=i+1;j<=9;j++) if(a[k]<a[j]) { k=j;//第一轮:1
阅读全文
摘要:#include <stdio.h> main() { float x=2.0,y=1.0,z=0.0,sum=0.0; int a; for(a=1;a<=20;a++) { sum=sum+x/y; z=x; x=x+y; y=z; } printf("%f",sum); getchar();
阅读全文