/*
Copyright (C) Wu.Meng-Da (Avogau.cis94)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
//(以上是版權宣告 把名字改成妳自己的)
//這版權宣告很炫 不可以砍掉
#include <stdio.h>
#include <iostream>
using namespace std;
const int MAX=48;
int main(int argc, char *argv[])
{
void change(char *);
char input[MAX];
do{
printf("輸入(或直接按enter結束程式):");
cin.getline(input,MAX,'\n');
change(input);
puts(input);
//cout<<input;
}while(input[0]!='\0');
return 0;
}
void love(char *input)
{
*(input-4)= (*(input-4) <= 'Z' && *(input-4) >='A') ? 'L' : 'l' ; //判斷大小寫
*(input-3)= (*(input-3) <= 'Z' && *(input-3) >='A') ? 'O' : 'o' ;
*(input-2)= (*(input-2) <= 'Z' && *(input-2) >='A') ? 'V' : 'v' ;
*(input-1)= (*(input-1) <= 'Z' && *(input-1) >='A') ? 'E' : 'e' ;
}
void change(char *input)
{
for(int i=0,count=0;i<strlen(input);i++) {
if((input[i] <= 'Z' && input[i] >='A') || (input[i] <= 'z' && input[i]>='a') ) {
count++; //讀到英文字時 count加1
}
else { //讀到非英文字母(含標點或數字) 視同本單字結束
if(count==4) { //判斷該單字是否長度為4
love(input+i); //call function來將單字改成 love
}
count=0; // 因單字結束 所以count規0
}
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.122.192
※ 編輯: avogau 來自: 140.113.122.192 (04/23 03:17)