用VC++编一个可以些英文1到100的程序.
11个回答
展开全部
由于英语水平和时间的问题有一些英文可能是错误的,自己该一下,不过程序可是经过运行的哦!运行环境xp-vc++ 6.0
#include<iostream>
#include<string>
int main()
{
using namespace std;
string a[19]={"One","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thrteen",
"fourteen","fivteen","eighteen","ninteen"};
string b[10]={"twenty","threty","fourty","fivety","sixty","seventy","eightty","ninty","one hunderen"};
int i=0;
for(i=1;i<=100;i++)
{
if(i<20) cout<<" "<<i<<"="<<a[i-1]<<" ";
else
{
if(i%10==0)
cout<<" "<<i<<"="<<b[i/10-2]<<" ";
else
cout<<" "<<i<<"="<<b[i/10-2]<<" "<<a[i%10-1]<<" ";
}
if(i%5==0) cout<<endl;
}
return 0;
}
#include<iostream>
#include<string>
int main()
{
using namespace std;
string a[19]={"One","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thrteen",
"fourteen","fivteen","eighteen","ninteen"};
string b[10]={"twenty","threty","fourty","fivety","sixty","seventy","eightty","ninty","one hunderen"};
int i=0;
for(i=1;i<=100;i++)
{
if(i<20) cout<<" "<<i<<"="<<a[i-1]<<" ";
else
{
if(i%10==0)
cout<<" "<<i<<"="<<b[i/10-2]<<" ";
else
cout<<" "<<i<<"="<<b[i/10-2]<<" "<<a[i%10-1]<<" ";
}
if(i%5==0) cout<<endl;
}
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不太懂你的意思,我写了一个C#的,给你参考一下:
public string getEnglishNumber(int indexnumber)
{
if(indexnumber>=0 && indexnumber<101)
{
string [] EnglishNumber={"one","two",…,"one hundred"};
return EnglishNumber[indexnumber].ToString();
}
return "";
}
private void Main()
{
int [] intnumber={1,2,5,7,…};
string EnglishNumbers="";
for(int i=0;i<intnumber.Length;i++)
EnglishNumbers+=getEnglishNumber(intnumber[i])+" ";
Response.WriteLine(EnglishNumbers);
}
public string getEnglishNumber(int indexnumber)
{
if(indexnumber>=0 && indexnumber<101)
{
string [] EnglishNumber={"one","two",…,"one hundred"};
return EnglishNumber[indexnumber].ToString();
}
return "";
}
private void Main()
{
int [] intnumber={1,2,5,7,…};
string EnglishNumbers="";
for(int i=0;i<intnumber.Length;i++)
EnglishNumbers+=getEnglishNumber(intnumber[i])+" ";
Response.WriteLine(EnglishNumbers);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
CString strA1;
strA1 = "one";
CString strA2;
strA2 = "two";
...
好吧,我承认我写累了……
strA1 = "one";
CString strA2;
strA2 = "two";
...
好吧,我承认我写累了……
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
该不是建立一个具有100个元素的字符串数组,然后初始化这个数组这么简单吧?理解力不太好,请楼主将问题描述详细点。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
楼主的意思是 one two three 。。。。 one hundred
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询