int main(int argc, char ** argv){ QCoreApplication app(argc,argv); QTextStream cin(stdin, QIODevice::ReadOnly); QTextStream cout(stdout, QIODevice::WriteOnly); QTextStream cerr(stderr, QIODevice::WriteOnly); RemoteFunctions::connect("http://192.168.220.100:8080/jsonrpc"); if(RemoteFunctions::ping()){ RemoteFunctions::printIntrospect(); //RemoteFunctions::getInfoLabls(); }else{ cout << "error"; } }
static int cin_wait(unsigned timeout) { int c = -1; /* start the timeout */ timer[TIMER_CIN] = timeout; do { c = cin(); if (c >= 0) break; } while (timer[TIMER_CIN] > 0); return c; }
void testAdder(){ bus a ("0001"); // 1 bus b ("0100"); // 4 bus sum(4); bus cout, cin("0"); Adder * adder = new Adder(a, b, cin, cout, sum); adder->evl(); std::cout << "The value on bus a is: " << a << std::endl; std::cout << "The value on bus b is: " << b << std::endl; std::cout << "Adding 1 + 4\n"; std::cout << "The sum is: " << sum << std::endl; std::cout << "The cout is: " << cout << std::endl; }
void Game::playGame(bool automatic) { QTextStream cout(stdout); QTextStream cin(stdout); quint8 player1_position = board->getPlayer(1)->getPosition(); quint8 player2_position = board->getPlayer(2)->getPosition(); quint8 goal_position = board->getGoal(); quint8 pit_position = board->getPit(); cout << board->getPlayer(1)->toString() << endl; cout << board->getPlayer(2)->toString() << endl; while (true) { this->board->movePlayer(1); player1_position = this->board->getPlayer(1)->getPosition(); cout << this->board->getPlayer(1)->toString() << endl; if (goal_position == player1_position) { cout << "The player 1 win" << endl; break; } else if (pit_position == player1_position) { cout << "The player 1 lose" << endl; break; } this->board->movePlayer(2); player2_position = this->board->getPlayer(2)->getPosition(); cout << this->board->getPlayer(2)->toString() << endl; if (goal_position == player2_position) { cout << "The player 2 win" << endl; break; } else if (pit_position == player2_position) { cout << "The player 2 lose " << endl; break; } if (false == automatic) { cin.readLine(); } } }
void Graph::readNM() { ifstream cin((folder+"/attribute.txt").c_str()); ASSERT(!cin == false); string s; while(cin >> s) { if(s.substr(0,2) == "n=") { n=atoi(s.substr(2).c_str()); continue; } if(s.substr(0,2) == "m=") { m=atoi(s.substr(2).c_str()); continue; } ASSERT(false); } cin.close(); cout << "[info] n = " << n << ", m = " << m << endl; }
int main() { ifstream cin("lp.in"); int i,j; while( cin>>n>>m && !cin.fail() ) { for(j=1; j<=n; j++) cin>>c[j]; cin>>ans; c[0]=0; for(i=1; i<=m; i++){ for(j=1; j<=n; j++) cin>>a[i][j]; cin>>rhs[i]; } switch( simplex(n, m, c, a, rhs, ans, x) ) { case OPTIMAL : printf("OPTIMAL\n%10lf\n",ans); for(j=1;j<=n;j++) printf("x[ %2d ] = %10lf\n",j,x[j]); break; case UNBOUNDED : printf("UNBOUNDED\n"); break; case INFEASIBLE : printf("INFEASIBLE\n"); break; } printf("\n"); } return 0; }
void main() { ifstream cin("hunger.in"); ofstream cout("hunger.out"); int B; int i , j; cin>>B; for (i=1;i<=B;i++) cin>>a[i]>>b[i]; for (i=1;i<B;i++) for (j=i+1;j<=B;j++) if (b[i]>b[j]) { int temp ; temp = a[i]; a[i] = a[j]; a[j] = temp; temp = b[i]; b[i] = b[j]; b[j] = temp; } for (i=1;i<=B;i++) { f[i]=0; for (j=1;j<i;j++) if (b[j]<a[i] && f[j]>f[i]) f[i]=f[j]; f[i]+=b[i]-a[i]+1; } int ans = 0; for (i=1;i<=B;i++) if (f[i]>ans) ans = f[i]; cout<<ans<<endl; }
int projecteuler018(void) { int i, j; int n = 15; int triMax; std::ifstream cin("projecteuler18.txt"); for(i = 0; i < n; i++) { for(int j=0;j<=i;j++) { cin >> fileTable[i][j]; } } triMax = topBottomTriangle(0, 0); printf("%d\n", triMax); for (i = 0; i < 15; i++) { for (j = 0; j < i; j++) { printf("%d ", fileTable[i][j]); } printf("\n"); } return 0; }
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); if (argc <= 3) { qWarning() << "Error, no output file loaded"; return 0; } QFile f1(argv[1]); f1.open(QIODevice::ReadOnly); QTextStream cin(&f1); QFile f2(argv[2]); f2.open(QIODevice::WriteOnly); QTextStream out1(&f2); QFile f3(argv[3]); f3.open(QIODevice::WriteOnly); QTextStream out2(&f3); QString dat0; QString dat1; while(not cin.atEnd()) { cin >> dat0; cin >> dat1; dat0 += " " + dat1; QDateTime d = QDateTime::fromString(dat0, "dd/MM/yyyy hh:mm:ss"); dat0 = d.toString("dd/MM/yyyy hh:mm:ss"); int day = d.date().day(); bool found = false; for (int i = 0; i < 7 and not found; ++i) found = day == days[i]; int n; cin >> n; uint nClasse = 0; uint sClasse = 0; uint nTot = 0; uint sTot = 0; for (int i = 0; i < n; ++i) { cin >> dat1; int temp; cin >> temp; int classe; cin >> classe; if (classe) { sClasse += temp; sTot += tot[i]; } else { nClasse += temp; nTot += tot[i]; } } if (found) continue; out1 << dat0 << "\t" << nClasse/double(nTot) << endl; if (sTot != 0) out2 << dat0 << "\t" << sClasse/double(sTot) << endl; } return 0; }
// Bootloader protocol logic // static void bootloader(void) { uint8_t c; uint8_t count, i; static uint16_t address; // Wait for a command byte LED_BOOTLOADER = LED_ON; c = cin(); LED_BOOTLOADER = LED_OFF; // common tests for EOC switch (c) { case PROTO_GET_SYNC: case PROTO_GET_DEVICE: case PROTO_CHIP_ERASE: case PROTO_PARAM_ERASE: case PROTO_READ_FLASH: case PROTO_DEBUG: if (cin() != PROTO_EOC) goto cmd_bad; } switch (c) { case PROTO_GET_SYNC: // sync break; case PROTO_GET_DEVICE: cout(BOARD_ID); cout(board_frequency); break; case PROTO_CHIP_ERASE: // erase the program area flash_erase_app(); break; case PROTO_PARAM_ERASE: flash_erase_scratch(); break; case PROTO_LOAD_ADDRESS: // set address address = cin(); address |= (uint16_t)cin() << 8; if (cin() != PROTO_EOC) goto cmd_bad; break; case PROTO_PROG_FLASH: // program byte c = cin(); if (cin() != PROTO_EOC) goto cmd_bad; flash_write_byte(address++, c); break; case PROTO_READ_FLASH: // readback byte c = flash_read_byte(address++); cout(c); break; case PROTO_PROG_MULTI: count = cin(); if (count > sizeof(buf)) goto cmd_bad; for (i = 0; i < count; i++) buf[i] = cin(); if (cin() != PROTO_EOC) goto cmd_bad; for (i = 0; i < count; i++) flash_write_byte(address++, buf[i]); break; case PROTO_READ_MULTI: count = cin(); if (cin() != PROTO_EOC) goto cmd_bad; for (i = 0; i < count; i++) { c = flash_read_byte(address++); cout(c); } break; case PROTO_REBOOT: // generate a software reset, which should boot to the application RSTSRC |= (1 << 4); case PROTO_DEBUG: // XXX reserved for ad-hoc debugging as required break; default: goto cmd_bad; } sync_response(); cmd_bad: return; }