Skullpiercer @ 2024-01-25 17:43:16
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int lenCalculate(char*start,char*end){
return (int)(end-start);
}
int main(){
char sentn[1001];
fgets(sentn,1001,stdin);
int len=strlen(sentn);
sentn[len-1]=' ';
sentn[len]='\0';
char*pe=sentn;
char*p1=sentn;
char*p2=sentn;
for(int i=0;i<len;i++){
if(*p1!=' '){
p1++;
}
else{
printf("%d",lenCalculate(p2,p1));
if(*((p1+1))==' '){
pe=p1;
do{
pe++;
}while(*pe==' ');
p1=pe;
p2=pe;
}
if(*p1!='\0'){
printf(",");
}
else{
break;
}
}
}
return 0;
}
for(int i=0;i<len;i++){
if(*p1!=' '){
p1++;
}
else{
printf("%d",lenCalculate(p2,p1));
if(*((p1+1))==' '){
pe=p1;
do{
pe++;
}while(*pe==' ');
p1=pe;
p2=pe;
}
if(*p1!='\0'){
printf(",");
}
else{
break;
}
}
}
return 0;
}
by 120229xhj @ 2024-03-14 20:35:53
e,试试函数,好像是sizeof(char数组名)
by yinzexuan @ 2024-07-04 17:41:48
666+QAQ