Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <stdlib.h>
- using namespace std;
- int main(){
- while(1){
- int m, n, k, b = 0, i[] = {0};
- while (1) {
- cout << "約瑟夫:";
- cin >> m >> n >> k;
- for (int a = 1; a <= m; a++) {
- i[a] = { a };
- }
- for (int x = 0; x < k; x++) {
- i[n] = { 0 };
- if (n > m) {
- n = 1;
- goto end;
- }
- end:
- n += 2;
- }
- cout << i[n] << endl;
- }
- system("PAUSE");
- system("CLS");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement