C++输出1~n之间所有的奇数_#include

#include <iostream>
using namespace std;

int main()
{
    int n,i = 1;
    cin >> n;
    do{
    	if (i % 2 == 1){
    		cout << i << " ";
		}
		i ++;
	} while (i <= n);
    return 0;
}
#include <iostream>
using namespace std;

int main()
{
	int n,i = 1;
	cin >> n;
	
	while (i <= n){
		if (i % 2 == 1) {
			cout << i << " ";
		}
		i ++;
	}
    return 0;
}