2022NEFU 作业八 持续更新中

9014
2022NEFU 作业八 持续更新中_第1张图片

#include 
#include 
#include 

int main()
{
    int n,i,j,k;
    int count[50];
    char ch[30][50],ch1[30][50],ch0[30][50];
    char tmp[]="\0";
    while(~scanf("%d ",&n))
    {
        for(i = 0;i < n;i++)
        {
            gets(ch[i]);
            strcpy(ch1[i],ch[i]);
        }
        for(i=0;i < n;i++)
            for(j=i+1;j<n;j++)
                if(strcmp(ch1[i],ch1[j]) == 0)
                       strcpy(ch1[j],tmp);
        k = 0;
        for(i = 0;i < n;i ++){
            count[i] = 0;
            if(strcmp(ch1[i],tmp) != 0){
                strcpy(ch0[k],ch1[i]);
                k++;
            }
        }
        for(i = 0;i < k;i++){
            for(j = 0;j < n;j++){
                if(strcmp(ch0[i],ch[j])==0){
                    count[i]++;
                }
            }
        }

        for(i = 0;i < k;i++){
            printf("%d ",count[i]);
            puts(ch0[i]);
        }
    }
    return 0;
}`

2022NEFU 作业八 持续更新中_第2张图片

#include 
#include 

int main()
{
    char ch[100],word[20][20];
    char tmp;
    int i,n,j,g;
    while(gets(ch)!=NULL)
    {
        i=0;
        n=0;
        while(ch[i]!='\0')
      {
        while(ch[i]>0&&ch[i]<'A'||ch[i]>'Z'&&ch[i]<'a'||ch[i]>'z')
            i++;
       if(ch[i]=='\0')
         break;
         j=0;
       while(ch[i]>='A'&&ch[i]<='Z'||ch[i]>='a'&&ch[i]<='z')
       {
         word[n][j]=ch[i];
         j++;i++;
       }
       word[n][j]='\0';
       int length = j;
       for(g = 0; g < length / 2;g++){
            tmp = word[n][g];
            word[n][g] = word[n][length - g - 1];
            word[n][length - g - 1] = tmp;
        }
       n++;
    }
    printf("%d\n",n);
     for(i=0;i < n-1;i++)
        printf("%s ",word[i]);
    printf("%s\n",word[i]);
    }
    return 0;
}

你可能感兴趣的:(c语言)