For Loop
题目:
输入两个整数 a,b。从 a到b进行输出,如果数值小于9则输出对应的英文字符串;如果数值大于9则判断输出奇偶英文字符串。
原题链接:link
Answer
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
// Complete the code.
int a,b;
string value[11] = {"even","odd","one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
cin >>a>>b;
for(int i=a;i<=b;i++){
if(i<=9){
cout<<value[i+1]<<endl;
}
if(i>9){
if((i%2)!=0){
cout<<value[1]<<endl;
}
else {
cout<<value[0]<<endl;
}
}
}
return 0;
}