C语编程题目
#include<stdio.h>
#include<string.h>
voidsum(char*sum,char*a,char*b)
{
char*s_short,*s_long;
inti_short,i_long,i_result;
i_short=strlen(a)-1;
i_long=strlen(b)-1;
if(i_long>=i_short)
{
s_short=a;
s_long=b;
i_result=i_long+1;
}
else
{
s_long=a;
s_short=b;
i_result=i_short;
i_short=i_long;
i_long=i_result;
i_result++;
}
for(;i_short>=0;i_short--,i_long--,i_result--)
{
sum[i_result]+=s_short[i_short]-'0'+s_long[i_long]-'0';
sum[i_result-1]=sum[i_result]/10;
sum[i_result]%=10;
sum[i_result]+='0';
}
for(;i_long>=0;i_long--,i_result--)
{
sum[i_result]+=s_long[i_long]-'0';
sum[i_result-1]=sum[i_result]/10;
sum[i_result]%=10;
sum[i_result]+='0';
}
if(sum[0])sum[0]+='0';
else
{
i_result=strlen(sum+1);
memmove(sum,sum+1,i_result);
sum[i_result]=0;
}
}
intmain(intargc,char**argv)
{
chara[1001]={0},b[1001]={0},r[1002]={0};
inti,j=0;
scanf("%d",&i);
while(j++<i)
{
memset(r,0,sizeof(r));
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
scanf("%s%s",a,b);
sum(r,a,b);
printf("Case%d: ",j);
printf("%s+%s=%s ",a,b,r);
if(j<i)printf(" ");
}
return0;
}
② C语言编程题目
#include <stdio.h>
char *StrCat(char *s,char *t)
{
int i=0,j=0;
char *s1,*t1;
s1=s;t1=t;
for(;*s1;s1++,i++);
for(;*t1;t1++,j++);
if(i<=j)
{
for(;*t;)*s1++=*t++;*s1='\0';
return s;
}
else
{
for(;*s;)*t1++=*s++;*t1='\0';
return t;
}
}
int main(int argc, char *argv[])
{
char a[100],b[100];
scanf("%s",a);
scanf("%s",b);
printf("%s",StrCat(a,b));
return 0;
}
③ c语言编程题
#include<歼宏stdio.h>
void main()
{
int max,min,sum,i,score[10];
printf("输入数据:");
for(i=0;i<判亩10;i++)
scanf("%d",&score[i]);
sum = max = min = score[0];
for(i=1; i<10; i++)
{
if(max<掘改森score[i])max = score[i];
if(min>score[i])min = score[i];
sum =sum+score[i];
}
printf("%.2f\n", (sum-min-max)/8.0);
}
④ C语言编程题,求解题思路!
只要按照公式计算每月还款金额就可以了,其中"已归还本金累计额"等于"贷款本金 除以 还款月数 乘以 已还款月数".
按照题目要求编写的等额本金还款的C语言程序如下
#include<stdio.h>
int main(){
double P,R,repayment;
int N,i;
scanf("%lf;%d;%lf",&P,&N,&R);
printf("[");
for(i=0;i<N;i++){
repayment=(P/N)+(P-P/N*i)*R;
if(i==N-1)
printf("%.2lf]",repayment);
else
printf("%.2lf,",repayment);
}
return 0;
}