【基礎練習】【模擬】codevs1704 卡片遊戲題解
阿新 • • 發佈:2019-02-19
題目描述 Description
桌面上有一疊牌,從第一張牌(即位於頂面的牌)開始從上往下依次編號為1~n.當至少還剩兩張排時進行一下操作:把第一張牌扔掉,然後把新的第一張牌放到整疊牌的最後。輸入n。輸出每次扔掉的牌,以及最後剩下的牌。。
輸入描述 Input Description輸入n
輸出描述 Output Description輸出每次扔掉的牌,以及最後剩下的牌
樣例輸入 Sample Input7
樣例輸出 Sample Output1 3 5 7 4 2 6
水題一道 資料範圍都沒給 而且也不需要如果資料很大可能要推規律
上程式碼
關鍵是一定要好好學習 馬上閉關了 閉關之前文化課也要搞好//ͼÂÛÒª¾¡¿ì»Ø¹Ë È»ºó ÖØÒªµÄÊÇÒªÁ·ÊÖËÙºÍ˼άģʽ ÒÔ¼°Ô¤±¸Ä£°å´úÂë //È»¶øÕâµÀÌâËƺõ²¢²»ÊÇͼÂÛ //codevs1704 ¿¨Æ¬ÓÎÏ· //copyright by ametake #include #include #include #include using namespace std; const int maxn=1000; int n; queue q; int main() { scanf("%d",&n); for (int i=1;i<=n;i++) q.push(i); while (!q.empty()) { printf("%d ",q.front()); q.pop(); int i=q.front(); q.pop(); if (!q.empty()) q.push(i); else printf("%d\n",i); } return 0; }
——苦恨年年壓金線,為他人作嫁衣裳。