【发布时间】:2017-11-23 09:20:14
【问题描述】:
我试图用谷歌搜索这个问题,但没有找到明确的答案。我正在为自己编写一个程序来练习英语和西班牙语。这很简单,我有我的单词词汇,所以我创建了一个代码,随机选择一个单词,显示在监视器中,第二个“Enter”将显示其他语言的翻译。现在我只做英语->西班牙语。但总的来说,我想做俄罗斯-> 英语加西班牙语。问题是不同的语言无法在 Windows 控制台中正确显示。我需要俄语 cyrylica、西班牙语特殊符号,如 ñ 和单词的英文转录。我用的是NetBeans IDE,它自己的console不能很好的处理scanf函数,所以只能用windows console。 有没有办法做到这一点? 这是代码。我使用随机生成的符号,然后使用附加代码来排除重复的数字。它只是一个原型,原始词汇有几千个单词。
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <time.h>
#define WORDS 25
void func_words(int rnd);
int main(void) {
system("COLOR B0");
srand((time)(NULL));
char ch;
int random;
int count=0;
int rand_array[1000];
int MATCH;
printf("\nPress Enter to continue:");
while(scanf("%c",&ch)&&ch=='\n')
{
for(int i=0;random=rand()%WORDS+1;i++)
{
MATCH=0;
rand_array[i]=random;
for(int j=0;j<i;j++)
{
if(random==rand_array[j])
MATCH++;
}
if(MATCH!=0)
continue;
func_words(random);
count++;
printf("\n%i\n",count);
if(count==WORDS)
break;
}
printf("\nFINISH!\n");
}
return 0;
}
void func_words(int rnd)
{
char ch2;
char *ar[WORDS][2]={
{"Costumbre","Habbit, bad habbit"},
{"Comer", "Eat, Eating, Meal"},
{"Beber", "Drink, you drink too much"},
{"Costumbre", "Habit, annoying habit"},
{"referirse", "Refer"},
{"el verbo", "Verb"},
{"Aplicar, emplear", "Apply, We applied to the authorities for assistance. To apply the new method"},
{"oración", "Sentence, make up a sentence, affirmative sentence"},
{"piel", "Skin, leather"},
{"las mejillas", "Cheek"},
{"bigote", "Moustache, Whisker"},
{"barba", "beard"},
{"las pestañas", "eyelash"},
{" lengua", "language tongue"},
{" los órganos internos", "internals "},
{"lung ", "los pulmones"},
{"liver ", "hígado"},
{"riñones", "Kidney "},
{"cuello", "neck "},
{"hueso", "Bones "},
{"músculo musculatura", "muscle "},
{"nervio", "Nerves "},
{"nervio", "breathe"},
{"Reír / risa", "laugh smile "},
{"mentón", "chin "},
{"las cejas", "eyebrow "},
{"", ""},
};
printf(" %s",ar[rnd-1][0]);
scanf("%c",&ch2);
printf("\n");
printf(" %s",ar[rnd-1][1]);
printf("\n---------------------------\n");
}
【问题讨论】: