回覆列表
  • 1 # lanfengz2

    #include

    using namespace std;

    int SIZE = 3;

    int main(int argc, char *argv[])

    {

    cout << "請輸入小於1000的正整數: ";

    int n;

    cin >> n;

    while(n < 0 || n > 1000)

    {

    cout << "輸入數字屬於1000以內正整數,請重新輸入:";

    cin >> n;

    }

    int count=0;

    int ar[SIZE];

    int i = 0;

    while(n > 0)

    {

    ar[i++] = n % 10;

    n /= 10;

    count++;

    }

    cout << "該輸入倒序輸入為:";

    for(int j = 0;j < count; j++)

    cout << ar[j];

    cout << endl;

    cout << "該數字為" << count << "位數" << endl;

    return 0;

    }

  • 中秋節和大豐收的關聯?
  • 思念是一種病,異地戀時要如何緩解思念?