简单模拟题。
CODE:
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#include "math.h"
#include "ctype.h"
using namespace std;
char a[101], str[101];
int main()
{
int i, j;
int t;
scanf("%d", &t);
getchar();
while (t--)
{
gets(a);
int len = strlen(a);
i = 0; j = 0;
while(a[i] == 32) i++;
if(islower(a[i])) str[j++] = a[i] - 32;
else str[j++] = a[i];
i++;
while (i < len-1)
{
if(a[i] == 32 && a[i+1] != 32)
{
if(islower(a[i+1])) str[j++] = a[i+1]-32;
else str[j++] = a[i+1];
}
i++;
}
str[j]='\0';
puts(str);
}
return 0;
#include "string.h"
#include "stdlib.h"
#include "math.h"
#include "ctype.h"
using namespace std;
char a[101], str[101];
int main()
{
int i, j;
int t;
scanf("%d", &t);
getchar();
while (t--)
{
gets(a);
int len = strlen(a);
i = 0; j = 0;
while(a[i] == 32) i++;
if(islower(a[i])) str[j++] = a[i] - 32;
else str[j++] = a[i];
i++;
while (i < len-1)
{
if(a[i] == 32 && a[i+1] != 32)
{
if(islower(a[i+1])) str[j++] = a[i+1]-32;
else str[j++] = a[i+1];
}
i++;
}
str[j]='\0';
puts(str);
}
return 0;
}
浙公网安备 33010602011771号