[Codeforces]1006A. Adjacent Replacements

題目URL:http://codeforces.com/contest/1006/problem/A
嘛......判斷偶數就減1,奇數不變,就可以輸出啦~


#include<bits/stdc++.h>
using namespace std;
int str[1005];
main()
{
    int num;
    cin >> num;
    for(int i=0;i<num;i++)
        cin >> str[i]; 
    for(int i=0;i<num;i++)
    {
        if(str[i]%2==0)
        cout << str[i]-1 << " ";
        else
        cout << str[i] << " ";
    }
    cout << endl;
    return 0;
}

留言

這個網誌中的熱門文章

[ZJ] b229: TOI 2009 第一題:路徑問題

交大資工(APCS組)(面試&心得)

滿是挫傷的ION CAMP