头像

QiyuanZqy




离线:17天前



QiyuanZqy
1个月前

先判断x是否为奇数,如是直接输出x,否则输出x+1(x后最近的奇数)
之后连续输出5个后面的奇数就行了

#include<bits/stdc++.h>
using namespace std;
int main(){
    int x;
    cin>>x;
    if(x % 2 != 0)cout<<x<<endl;
    else cout<<++x<<endl;
    for(int i = 0;i < 5;i++){
        cout<<x+2<<endl;
        x += 2;
    }
    return 0;
}



QiyuanZqy
1个月前

switch语句…

 #include<bits/stdc++.h>
using namespace std;
int main(){
    int ddd;
    cin>>ddd;
    switch(ddd){
        case 61:cout<<"Brasilia";break;
        case 71:cout<<"Salvador";break;
        case 11:cout<<"Sao Paulo";break;
        case 21:cout<<"Rio de Janeiro";break;
        case 32:cout<<"Juiz de Fora";break;
        case 19:cout<<"Campinas";break;
        case 27:cout<<"Vitoria";break;
        case 31:cout<<"Belo Horizonte";break;
        default:cout<<"DDD nao cadastrado";break;
    }
    return 0;
}