c语言小练习

Python027

c语言小练习,第1张

测试结果:

请输入字符串s:

Louzhu,

请输入字符串t:

Hello!

Louzhu,Hello!

请按任意键继续. . .

源代码:

#include <stdio.h>

#include <stdlib.h>

#include<math.h>

void stracat(char a[],char b[])

{

char *p=a

char *q=b

while(*q!='\0')

q++

while(*p!='\0')

*q++=*p++

}

main()

{

char t[100]={'\0'},s[100]={'\0'}

printf("请输入字符串s:\n")

scanf("%s",s)

printf("请输入字符串t:\n")

scanf("%s",t)

stracat(t,s)

printf("%s\n",s)

system("pause")

}

#include "stdio.h"

int Judge(const char *a,const char *b){

int s,n

for(s=n=0n<10s+=a[n]==b[n++])

return s

}

int main(int argc,char *argv[]){

const char std[]="ABCDBBCBBC"

char ans[10],i,t

printf("Please enter your answer(orderly sequence of ABCD)...\n")

while(1){

if(scanf("%10s",ans)==1)

for(i=0i<10i++)

if(ans[i]!='A' &&ans[i]!='B' &&ans[i]!='C' &&ans[i]!='D')

break

if(i>=10)

break

printf("Input error, redo:\nPlease enter your answer(orderly sequence of ABCD)...\n")

}

printf("\nCorrect answer:\n")

for(t=Judge(std,ans),i=0i<10i++)

if(std[i]==ans[i])

printf("%2d",i+1)

printf("\nTOTAL: %d\n",10*t)

return 0

}

代码格式和运行样例图片:

#includeint main(){double s int a[10000] int i,n,d while(~scanf("%d",&n)){d=0 s=0 for(i=0i=60) d++ printf("average = %.1lf\ncount = %d\n",s,d) }return 0}