1、1注:答案仅供参考分期还款:#include #include int main()double d, p,r;scanf(“%lf%lf%lf“,printf(“%.1f“, log10(p/(p-d*r)/log10(1+r);return 0;计算分段函数函数值:#include int main()double x;scanf(“%lf“,if(x=1 scanf(“%d“, if(score100 | score=90)printf(“A“);else if(score=80)printf(“B“);else if(score=70)printf(“C“);else if(score
2、=60)printf(“D“);elseprintf(“E“);return 0;220 秒后时间:#include #include int main()int h,m,s;scanf(“%d:%d:%d“, s=s+20;if(s59)s=s%60;m+;if(m59)m=m%60;h+;if(h23)h=0;printf(“%02d:%02d:%02dn“, h, m, s);return 0;分期还款(加强版):#include #include int main()double d, p,r;scanf(“%lf%lf%lf“,if(d=0)printf(“0.0n“);else i
3、f(d*(1+r)-pd)printf(“Godn“);elseprintf(“%.1f“, log10(p/(p-d*r)/log10(1+r);return 0;字母分类统计:#include 3#include int main()char ch;int nL=0, nN=0, nS=0, nO=0;while(ch=getchar()!=n)if(ch=adouble a=2,b=1,s=0;scanf(“%d“,for(i=1;i#include int main()double sum=-100, d=100;int i,n;scanf(“%d“, for(i=1; i#inclu
4、de int main()double a, x0, x1=1;scanf(“%lf“, dox0=x1;x1=1.0/2*(x1+a/x1);while(fabs(x1-x0)=1e-5);printf(“%.4lfn“, x1);return 0;打印三角形:#include #define abs(x) (x)=0?(x):-(x)int main()int n,i,j;scanf(“%d“, for(i=-(n-1); i#include 5int main()int i,j,k,n;scanf(“%d“, for(i=1; i=0; i-)if(ain) ai+1=ai;else b
5、reak;ai+1=n;输出不同的数:#include“stdio.h“main() int a20;int i,t,p=0;for(i=0;i#include int main()int i,j,a34,flag=0,col,r;for(i=0;iaicol) col=j;for(j=0;j=j)printf(“Y“);elseprintf(“N“);ASCII 码值之和的差:#include int sum(char *s)int t=0,i=0;while(si!=0)t+=si+;7return t;int main()char s181,s282;gets(s1);gets(s2);
6、printf(“%d“, sum(s1)-sum(s2);return 0;所有数字之和:#include “stdio.h“ int sum(int n) int ret=0;while(n0)ret+=n%10;n/=10;return ret; main() int n; scanf(“%d“, printf(“%d“, sum(n); 元音字母:#include “stdio.h“ void yuan(char *s,char *s2) while(*s!=0)if(*s=a |*s=o |*s=e |*s=i |*s=u |*s=A |*s=O |*s=E |*s=I |*s=U)*
7、s2=*s; s2+;s+;*s2=0; 8main() char str81, str281; gets(str); yuan(str,str2); printf(“%s“, str2); 字符统计:#include #include #include int nL=0, nN=0; int statistics(char *s) int ret=0;while(*s!=0)if(*s=a for(i=0;iaj) k=j; tmp=ak;ak=ai;ai=tmp; int main() int a10; int i; for(i=0; i int F(int x, int n) if(n=1) return x; else return F(x, n-1)*x; int main() int x, n; scanf(“%d%d“, printf(“%d“, F(x, n); return 0; 行列互换:#include void swap(int *a, int *b) int temp; 10temp=*a;*a=*b;*b=temp; void col(int a4, int i, int j) int k;for(k=0; k void average(double a5, int n) int i,j;double sum;