天天看點

OJ字元串多組輸入問題

字元串多組輸入問題
OJ字元串多組輸入問題

#include <stdio.h>
#include <stdlib.h>
#include<string.h>
int main()
{
    int n,i,j,l,tt;
    scanf("%d",&n);
    char a[101];
    char b='a';
    while(gets(a)!=NULL)
    {
        n=strlen(a);
        for(i=0; i<n; i++)
        {
            if(i==0||a[i-1]==' ')
            {
                printf("%c",a[i]-32);
            }
            else printf("%c",a[i]);
        }
        printf("\n");
    }
    
    return 0;
}

           

多組輸入字元串while((scanf("%s",a))!=EOF)

要求字元串帶空格的可以用while(gets(a)!=NULL過OJ

繼續閱讀