随笔分类 - C语言填空
摘要:#include <stdio.h> //求s=1+2+3+4+...+100 main() { int a=101,【1】; while(【2】,a>0) s【3】=【4】; printf("s=%d",s); getchar(); } #include <stdio.h> //求s=1+2+3+
阅读全文
摘要:#include <stdio.h> //执行下列程序段后,y的值是(),x的值是(), m的值是(),n的值是() main() { int x,y,z,m,n; m=10;n=5; x=(--m==n++)?--m:++n; y=m++; getchar(); } #include <stdio
阅读全文
摘要:#include <stdio.h> //求两个数中的最大值 int max(int a,int b) { return 【1】; } main() { int a,b; scanf("%d%d",【2】); printf("max=%d",【3】); getchar(); } #include <
阅读全文
摘要:#include <stdio.h> //求任意整数的阶乘 //如果输入3则输出3!=6 main() { int n,a,c=1; scanf("%d",&n); for(a=1;【1】;a++) c=【2】; printf("%d!=%d",【3】); getchar(); } #include
阅读全文
摘要:#include <stdio.h> //找出100-999间所有的Armstrong数 //Armstrong数:指这个3位数各位上数字的立方和等于自身 //371=3*3*3+7*7*7+1*1*1 main() { int i,a,b,c; for(i=100;i<=999;i++) { a=
阅读全文
摘要:#include <stdio.h> //求出a中各相邻两个元素的和,并将这些和存放在数组b中 //按每行3个元素的形式输出。例如:b[1]=a[1]+a[0],....,b[9]=a[9]+a[8] main() { int a[10],b[10],i; printf("\nInput 10 nu
阅读全文
摘要:#include <stdio.h> //输入一行英文,输出单词个数 #include <string.h> main() { char zf[101]; int a,b,【1】; 【1】; a=【1】; for(b=0;【1】;b++) if(zf[b]==【1】) c++; c=【1】; pri
阅读全文
摘要:#include <stdio.h> //输入5个1-9之间的整数,输出其中的最大值和最小值 main() { int a[5],i,j,temp,【1】; for(i=0;i<5;i++) scanf("%d",&a[i]); for(i=0;i<4;i++) for(j=【1】;j<5;j++)
阅读全文
摘要:#include <stdio.h> //从键盘输入一个年份和月份,输出该月的天数 main() { int year,month; scanf("【1】",&year,&month); switch(month) { case 1: case 3: case 5: case 7: case 8:
阅读全文
摘要:#include <stdio.h> //调用函数f,从字符串中删除所有的数字字符 asdf32asdfadsfds\0 数组 #include <string.h> void f(char *s) { int i=0; while(【1】) { if(s[i]>='0' && s[i]<='9')
阅读全文
摘要:#include <stdio.h> //调用函数计算代数多项式1.1+2.2*x+3.3*x*x+4.4*x*x*x+5.5*x*x*x*x //当x=1.7时的值 float f(float,float*,int) ; main() { float b[5]={1.1,2.2,3.3,4.4,5
阅读全文
摘要:#include <stdio.h> //程序功能:调用函数f,将一个整数首尾倒置 //如程序输入12345,则输出54321 // 如程序输入-12345,则输出-54321 #include <math.h> int f(int n) { int m,y=0;m=abs(n); while(m!
阅读全文
摘要:#include <stdio.h> //->是一个整体,它是用于指向结构体子数据的指针,用来取子数据。 //换种说法,如果我们在C语言中定义了一个结构体,然后申明一个指针指向这个结构体, //那么我们要用指针取出结构体中的数据,就要用到->。 //计算四位学生的平均成绩,保存在结构体中,然后列表输
阅读全文
摘要:#include <stdio.h> //将字符串的所有的字符's'删除 ,并输出修改后的字符串 main() { char a[80]; int i,j; 【1】; for(【2】;a[i]!=【3】;i++) if(a[i]!='s') { 【4】=a[i]; j++; } a[j]=【5】;
阅读全文
摘要:#include <stdio.h> //数列的第1 2项值为1,此后各项值均为该项前二项之和,计算数列第30项的值 int f(int n); main() { printf("%d",【1】); getchar(); } int f(int n) { if(n==1 || n==2) 【2】;
阅读全文
摘要:#include <stdio.h> //将任意三个整数按 从小到大排序 void swap(【1】,【2】) { int temp; temp=*pa; *pa=*pb; *pb=temp; } main() { int a,b,c,temp; scanf("%d%d%d",&a,&b,&c);
阅读全文
摘要:#include <stdio.h> //求输入的整数各位数字之和。如输入234则输出9;输入-123则输出6 main() { int n,【1】; scanf("%d",&n) ; n=【2】; while(【3】) { s=s+【4】; n=【5】; } printf("%d",s); get
阅读全文
摘要:#include<stdio.h> //将任意10进制整数转化为2-16任意进制 int main() { char ku[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; int zh[32],i=0,w,
阅读全文
摘要:#include <stdio.h> //将10进制正整数转化为二进制 【5】 dec2bin(int m) { int bin[32],j; for(j=0;【1】;j++) { bin[j]=【2】; m=【3】; } for(;【4】;j--) printf("%d",bin[j-1]); }
阅读全文
摘要://功能:对=1,2,3,4,5,6,..,9,10 //求f(x)=x*x-5*x=sin(x)的最大值 并保留两位小数 #include <stdio.h> 【1】 【2】 f(x) x*x-5*x+sin(x) main( ) { int x;float max; max=【3】; for(x
阅读全文