9 条题解
-
3
先建一个string数组a,然后存入1~9的单词,判断n是否大于9,是就输出out,不是就输出a[n-1]
参考代码(已AC):
#include <bits/stdc++.h> using namespace std; int n; string a[9]={"one","two","three","four","five","six","seven","eight","nine"}; int main() { cin>>n; if(n>9) cout<<"out"; else cout<<a[n-1]; return 0; }
-
1
#include<iostream> using namespace std; int main() { int n; cin>>n; if(n>0 && n<10) { if(n==1) cout<<"one"; else if(n==2) cout<<"two"; else if(n==3) cout<<"three"; else if(n==4) cout<<"four"; else if(n==5) cout<<"five"; else if(n==6) cout<<"six"; else if(n==7) cout<<"seven"; else if(n==8) cout<<"eight"; else if(n==9) cout<<"nine"; } else { cout<<"out"; } return 0; }
-
0
#include<bits/stdc++.h> using namespace std; int main() { int c; cin >> c; if(c == 1) { cout << "one"; } else if (c == 2) { cout << "two"; } else if (c == 3) { cout << "three"; } else if (c == 4) { cout << "four"; } else if (c == 5) { cout << "five"; } else if (c == 6) { cout << "six"; } else if (c == 7) { cout << "seven"; } else if (c == 8) { cout << "eight"; } else if (c == 9) { cout << "nine"; } else { cout << "out"; } return 0; }
原始算法 A
-
0
这道题就是无脑判断…… 话不多说,直接上代码!
#include <bits/stdc++.h> using namespace std; int n; int main() { cin >> n; if (n == 1) { cout << "one"; } else if (n == 2) { cout << "two"; } else if (n == 3) { cout << "three"; } else if (n == 4) { cout << "four"; } else if (n == 5) { cout << "five"; } else if (n == 6) { cout << "six"; } else if (n == 7) { cout << "seven"; } else if (n == 8) { cout << "eight"; } else if (n == 9) { cout << "nine"; } else { cout << "out"; } return 0; }
-
0
题不难,就是耗时间 最笨最简单的方法:
#include <iostream> using namespace std; int main() { int n; cin >> n; if(n > 9)//如果大于九,输出“out” { cout << "out"; } else { if(n == 1)//一 { cout << "one"; } if(n == 2)//二 { cout << "two"; } if(n == 3)//三 { cout << "three"; } if(n == 4)//四 { cout << "four"; } if(n == 5)//五 { cout << "five"; } if(n == 6)//六 { cout << "six"; } if(n == 7)//七 { cout << "seven"; } if(n == 8)//八 { cout << "eight"; } if(n == 9)//九 { cout << "nine"; } } return 0; }
-
0
号没了
#include <iostream> using namespace std; int main() { int n; cin >> n; if(n>9) { cout << "out"; } else { if(n==1) { cout << "one"; } if(n==2) { cout << "two"; } if(n==3) { cout << "three"; } if(n==4) { cout << "four"; } if(n==5) { cout << "five"; } if(n==6) { cout << "six"; } if(n==7) { cout << "seven"; } if(n==8) { cout << "eight"; } if(n==9) { cout << "nine"; } } }
-
0
#include<cstdio> using namespace std; int main() { int a; scanf("%d",&a); if((a>=1)&&(a<=9)) { switch(a) { case 1:printf("one")break;; case 2:printf("two");break; case 3:printf("three");break; case 4:printf("four");break; case 5:printf("five");break; case 6:printf("six");break; case 7:printf("seven");break; case 8:printf("eight");break; case 9:printf("nine"); } } return 0; }
- 1
信息
- ID
- 44
- 时间
- 1000ms
- 内存
- 16MiB
- 难度
- 2
- 标签
- 递交数
- 289
- 已通过
- 175
- 上传者