速度!!!c 语言题目求解,一题十分……

2024-12-21 20:42:58
推荐回答(2个)
回答1:

#include

#include

void strmcpy(char *s,char *t,int m)

{

strcpy(s,t+m-1);

}


void main()

{

char s[100],t[100];

int m;

printf("Input a string: ");

gets(t);

printf("Input an integer: ");

scanf("%d",&m);

strmcpy(s,t,m);

printf("Output is: ");

puts(s);

}

#include

void main()

{

char s[100];

printf("Input a string:");

gets(s);

char *p=s;

int a[5]={0};

while(*p!='\0')

{

if(*p>='A'&&*p<='Z')

a[0]++;

else if(*p>='a'&&*p<='z')

a[1]++;

else if(*p==' ')

a[2]++;

else if(*p>='0'&&*p<='9')

a[3]++;

else

a[4]++;

p++;

}

printf("Number of uppercase letters is: %d\n",a[0]);

printf("Number of lowercase letters is: %d\n",a[1]);

printf("Number of spacebars is: %d\n",a[2]);

printf("Number of digits is: %d\n",a[3]);

printf("Number of other characters is: %d\n",a[4]);

}

回答2:

#includeintmain(){inti,j,n;floats=0.0;scanf("%d",&n);for(i=1;i