ACM初賽題---C語言實現

Description

你們是否是對第一次輸出Hello World的編程實驗還記憶猶新呢?接下來這道題就像當年輸出Hello World那樣簡單。要求:給出一個字符串,統計出字符串中大寫字母的數量,輸出該字符串並在字符串的後面輸出同等數量的感嘆號「!」。是否是很簡單?解決它吧!編程



Input

  第一行輸入一個數字T,表明T組數據。接下來T行,每行包括一個字符串(僅含大小寫英文字母,字符串長度在1到100之間)。ide


Output

對於每組數據,單獨輸出一行,即題目所求的字符串。spa



Sample Input

3
HelloWorld
abc
GOOD
orm

Sample Output

HelloWorld!!
abc
GOOD!!!!


代碼:
#include<stdio.h>
#include<string.h>
int main(){

int i=0,j,T,count=0;
char word[100],cat,b[100];
scanf("%d",&T);  
getchar();
while(T>0)
{    gets(word);
for(i=0;i<strlen(word);i++)
{
if(word[i]>='A'&&word[i]<='Z')
count++;
}
for(j =0 ;j < count;j++)
{ cat= strcat(word,"!"); }
   puts(cat);    
printf("\n");
T--;
} return 0;

ip

相關文章
相關標籤/搜索