请设计程序实现功能如下:
发布网友
发布时间:2023-11-24 09:38
我来回答
共2个回答
热心网友
时间:2024-12-02 19:15
先用strtok按空格划分单词,再将最后一个变为大写,最后输出
假设输入为strSym (VC++实现)
char *pChar = new char[strSym.GetLength() + 1] ;
sprintf(pChar,"%s",strSym);
char* token = "";
const char* seps = " ";
token = strtok(pChar,seps);
CString str,strout;
strout = "";
while (token != NULL)
{
str = token;
CString str1 = str.right(1);
int len = str.GetLength();
token = strtok( NULL, seps );
strOut+=str.left(len-1)+str.MakeUpper();
}
delete[] pChar;
cout << strOut
}
热心网友
时间:2024-12-02 19:15
另存为x.html 运行试试
<style type="text/css">
.upcase{text-transform:uppercase;}
</style>
<input type="text" name="word" id="word" size="64" maxlength="64" onchange="dosth();" />
<div id="result"></div>
<script type="text/javascript">
function dosth(){
var s = document.getElementById('word').value;
s = s.replace(/(\w[ .,]|\w$)/g,'<span class="upcase">$1</span>');
var r = document.getElementById('result');
r.innerHTML = s;
}