本文目录一览:
c++ 程序中二级指针的用法
PP---PS----数组首地址
(PP是变量PS的地址,*PP是取PS地址单元中的内容,因为PS单元中存放的是数组地址,所以*PP是数组首元素地址,**pp是数组首元素的值)
while(**pp==' ')
(*pp)++;
判断数组元素是否为空格
while(**pp**pp!=' ')
*pw++=*(*pp)++;
*pw='/0';
如果不为空 ,顺序赋值
怎么修改这个代码让他变成每个单词只出现一次
功能已实现.
在ie6,火狐下调试没bug.
出现过的单词以后将不会再出现.
(如果一开始是点击随机给出日语发音,
再点击随机给出日语单词,
将会使生词列表重置.我觉得这样会更符合使用习惯).
下面是代码.有注释.copy使用即可.同时我修改了些html,因为有的不规范.
程序整体结构还是沿用了你给的程序的算法,
其实还有很大的重构余地,我没时间了,没进行额外的设计,就照你那个来了.(你上面给的那个太不OO了)
代码:
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
""
htmlheadtitle日语记单词/title/headbody
br/br/br/br/
form
input id="button1" type="button" value="看日语发音" onclick='showPronunciation();'/
input type="text" size="40" value="Pronunciation" id="Pronunciation"/
br/br/
input id="button2" type="button" value="看日语单词" onclick='showJapanese()'/
input type="text" size="40" name="Japanese" value="Japanese" id="Japanese"/
br/br/
input id="button3" type="button" value="看中文意思" onclick='showChinese()'/
input type="text" size="40" name="Chinese" value="Chinese" id="Chinese"/
br/br/br/br/br/
input type="button" value="随机给出日语发音" onclick='randomPronunciation()'/
input type="button" value="随机给出日语单词" onclick='randomJapanese()'/
input type="button" value="随机给出中文意思" onclick='randomChinese()'/
/form
div id="alertArea"/div
script type="text/javascript"
var PronunciationArray = new Array();
var JapaneseArray = new Array();
var ChineseArray = new Array();
/*
后面这三个数组用于存储看过的单词.
*/
var ProArray = new Array();
var JapArray = new Array();
var ChiArray = new Array();
var nextWord;
var clicked; //click的作用是重置PronunciationArray这三个数组
/*
初始化生词数组,清空已经看过的单词数组
*/
function initWord(){
PronunciationArray[0]="あう ";
JapaneseArray[0]="合う、会う、遭う ";
ChineseArray[0]="见面,合适,遭遇 ";
PronunciationArray[1]="あじわう ";
JapaneseArray[1]="味わう ";
ChineseArray[1]="品尝,鉴赏 ";
//我额外加了几个单词,方便测试,不过我日语苦手,就写了几个简单的.
PronunciationArray[2]="シュ-トPronunciation ";
JapaneseArray[2]="シュ-ト ";
ChineseArray[2]="射门 ";
PronunciationArray[3]="パス Pronunciation";
JapaneseArray[3]="パス ";
ChineseArray[3]="传球 ";
PronunciationArray[4]="タックル Pronunciation";
JapaneseArray[4]="タックル ";
ChineseArray[4]="铲球 ";
PronunciationArray[5]="ドリブル Pronunciation";
JapaneseArray[5]="ドリブル ";
ChineseArray[5]="运球 ";
ProArray = new Array();
JapArray = new Array();
ChiArray = new Array();
}
function randomPronunciation(){
if(clicked != 1){
document.getElementById('alertArea').innerHTML = '';
initWord();
}
if(PronunciationArray.length0){
nextWord = Math.floor(Math.random()*PronunciationArray.length);
document.getElementById('Pronunciation').value = PronunciationArray[nextWord];
delelteWord(nextWord);
resetButton();
document.getElementById('button1').disabled = true;
document.getElementById('Japanese').value = "";
document.getElementById('Chinese').value = "";
}else{
document.getElementById('alertArea').innerHTML = '已经是最后一个单词了!';
}
clicked = 1;
}
function randomJapanese(){
if(clicked != 2){
document.getElementById('alertArea').innerHTML = '';
initWord();
}
if(JapaneseArray.length0){
nextWord = Math.floor(Math.random()*JapaneseArray.length);
document.getElementById('Japanese').value = JapaneseArray[nextWord];
delelteWord(nextWord);
resetButton();
document.getElementById('button2').disabled = true;
document.getElementById('Pronunciation').value = "";
document.getElementById('Chinese').value = "";
}else{
document.getElementById('alertArea').innerHTML = '已经是最后一个单词了!';
}
clicked = 2;
}
function randomChinese(){
if(clicked != 3){
document.getElementById('alertArea').innerHTML = '';
initWord();
}
if(ChineseArray.length0){
nextWord = Math.floor(Math.random()*ChineseArray.length);
document.getElementById('Chinese').value = ChineseArray[nextWord];
delelteWord(nextWord);
resetButton();
document.getElementById('button3').disabled = true;
document.getElementById('Pronunciation').value = "";
document.getElementById('Japanese').value = "";
}else{
document.getElementById('alertArea').innerHTML = '已经是最后一个单词了!';
}
clicked = 3;
}
function showPronunciation() {
if(ProArray.length=1)
document.getElementById('Pronunciation').value = ProArray[ProArray.length-1];
}
function showJapanese() {
if(JapArray.length=1)
document.getElementById('Japanese').value = JapArray[JapArray.length-1];
}
function showChinese() {
if(ChiArray.length=1)
document.getElementById('Chinese').value = ChiArray[ChiArray.length-1];
}
/* 删除刚看过的单词 同时向ProArray,JapArray,ChiArray三个数组push这个单词 */
function delelteWord(i){
ProArray.push(PronunciationArray[i]);
delArrElement(PronunciationArray,PronunciationArray[i]);
JapArray.push(JapaneseArray[i]);
delArrElement(JapaneseArray,JapaneseArray[i]);
ChiArray.push(ChineseArray[i]);
var chi = delArrElement(ChineseArray,ChineseArray[i]);
}
/* 删除数组中的一个元素,返回删除后的数组 */
function delArrElement(arr,element)
{
var j=0;
for(i=0;iarr.length;i++)
{
if(arr[i]==element)
{
break;
}
j++;
}
arr.splice(j,1);
return arr;
}
/* 重置按钮*/
function resetButton(){
for(var i=1;i=3;i++){
document.getElementById('button'+i).disabled = false;
}
}
/script
/body
/html
请VB语言高手帮我翻译下下面的东西谢谢了
好多错误啊,看这段代码大概功能是把输入的一段英文中的每一个词的第一个字母放到这个词的最后并输出,比如输入i am a student输出的是i ma a tudents
//要求变量声明
Option Explicit
//定义一个窗体级局部字符变量putword
Dim putword As String
//窗体的单击事件
Private Sub Form_click()
//定义字符变量phrase和nextword,整形变量Blankposition
Dim phrase As String,nextword As String,Blankposition As Integer
//用输入对话框输入一句英文赋值给phrase
phrase=InputBox(请输入一句英文)
//找到phrase中空格的位置,赋值给Blankposition
Blankposition=InStr(1,phrase," ")
//循环,条件是Blankposition不为0,就是说phrase中仍然含有空格,有一个以上的词
Do While Blankpositon0
//把第一个空格之前的字符,也就是第一个词赋值给nextword
newtword=Left(phrase,Blankposition-1)
//用来连接字符,把nextword的最左一个字符放到最右边并加入putword
putword=putwordRight(nettword,Len(nexword)-1)Left(nextword,1)" "
//截取phrase第一个空格之后的字符
phrase=Right(phrase,Len(phrase)-Blankposition)
//得到新的phrase中空格位置
Blankposition=Instr(1,phrase," ")
Loop
//把剩下最后一个不含空格的词做上面的调整
nextword=phrase
print newtword
putword=putwordRight(nextword,Len(nextword)-1)Left(nexword,1)""Print putword
End Sub
还有不明白的吗?