//************************1004***************************
#include
#include
#include
int main()
{
char a[31],b[31],c[31],smallStr[31],bigStr[31];
int small,big,temp,str1_len,str2_len,i,j,goHead=0,k;
while(scanf("%s %s",a,b)!=EOF)
{
str1_len=strlen(a);//输入a的长度
str2_len=strlen(b);//输入b的长度
i=str1_len;
j=str2_len;
if(i>=j)
{
small=j;
big=i;
for(i=0;i0;k--)
{
if(small>0)
{
temp=bigStr[k-1]-48+smallStr[small-1]-48+goHead;
small--;
}
else
{
temp=bigStr[k-1]+goHead-48;
}
if(temp>=10)
{
goHead =1;
c[k] = temp+38;
}
else
{
goHead=0;
c[k] = temp+48;
}
}
c[big+1]='\0';
if(goHead==1)
c[0]=49;
else
{
for(i=0;i<=big;i++)
{
c[i]=c[i+1];
}
}
printf("%s\n",c);
goHead=0;
}
}
A word defined as a string that contains only letters. Its length is defined as the string length. Two adjacent valid words are separated by spaces or (and) digits.
Write a program to figure out the longest word and its length in a one-line text. Suppose the text is shown by a string, comprised of letters, spaces and digits.
Several strings, one string on each line (the number of characters on each line does not exceed 200). Each string is a test case (text). Input is terminated by EOF.
For each test case, print out the longest word and its length with the format: word[space]:[space]length.
If there are n (n >= 2) words have the same longest length, print them with the format:
word1[space]:[space]length, [space]word2[space]:[space]length, [space]……, [space] wordn[space]:[space]length.
#include
#include
#include
int main()
{
char line[200];
char getN;
int first[200];
int length[200];
int i,n,num1,j,k,num2;
int tempf,templ,m,flag;
while(scanf("%[^\n]",line)!=EOF)
{
gets(&getN);
k=-1;m=1;n=0;
memset(first,0,sizeof(first));
memset(length,0,sizeof(length));
//scanf("%[^\n]",line);
num1=strlen(line);
for(i=0;i