Пример #1
0
Файл: pb1.c Проект: iulianR/labs
int main()
{
	Graph g;
	readG(g);
	printG(g);
	delNode(g, 3);
	printf("Graful dupa stergerea nodului 3\n");
	printG(g);
	return 0;
}
Пример #2
0
void printG(node *tree,int level)
{
if(tree== NULL ){return;}
if (level==1){
if((h(tree->left)-h(tree->right))>1 | (h(tree->right)-h(tree->left))>1 )
    printf("%d ",tree->data);}
else if (level > 1)
{
    printG(tree->left, level-1);
    printG(tree->right, level-1);
}
}
Пример #3
0
int main(int argc, char *argv[])
{
    int t, ct = 0;
    char op[100];
    scanf("%d", &t);
    while (t--) {
        printf("Case #%d:\n", ++ct);
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                scanf("%d", &currentState[i][j]);
            }
        }
        scanf("%s", op);
        memset(nextState, 0, sizeof(nextState));
        switch(op[0]) {
            case '>':
                right();
                break;
            case '<':
                left();
                break;
            case 'v':
                down();
                break;
            case '^':
                up();
                break;
            default:
                break;
        }
        printG();
    }
    return 0;
}
Пример #4
0
int main()
{
    int m, n;
    while(scanf("%d %d\n", &m, &n) != EOF && m != 0) {
        out("m %d n %d\n", m, n);
        int idCounter = 0;
        int grid[100][100] = {{0}};
        int id[100][100] = {{0}};
        int i, j;

        for(i=0;i<m;i++) {
            for(j=0;j<n;j++)
                scanf("%c", &grid[i][j]);
            scanf("\n");
        }
        printG(grid, m, n);

        for(i=0;i<m;i++) {
            for(j=0;j<n;j++) {
                if(isSet(grid, i, j, m, n) && id[i][j] == 0) {
                    id[i][j] = ++idCounter;
                    bfs(grid, id, m, n, i, j);
                }
            }
        }
        printf("%d\n", idCounter);
    }
    return 0;
}
Пример #5
0
void printErrorReport(struct gameState *testG, struct gameState *oracleG, struct gameState *beforeG, int playerArray[4], int i) {
    int j = 0;
    int thisPlayer = 0;
    printf("Test number %d failed.  Report: \n", i);
    for (i = 0; i < 4; ++i)
    {
        thisPlayer = playerArray[i];
        printf("\nbeforeG: (state after randomizing, but before card was played\n");
        printG(beforeG, thisPlayer);
        printf("\ntestG:\n");
        printG(testG, thisPlayer);
        printf("\noracleG:  (note: numBuys = expected treasureCards)\n");
        printG(oracleG, thisPlayer);
    }
    printf("--------------------------------------------------------------\n\n");
}
Пример #6
0
void printAngela(int x, int y) {
	printA(x,y);
	printN(x+3*SIZE+GAP,y);
	printG(x+7*SIZE+2*GAP,y);
	printE(x+12*SIZE+3*GAP,y);
	printL(x+15*SIZE+4*GAP,y);
	printA(x+18*SIZE+5*GAP,y);
}
Пример #7
0
 int main(){
      freopen("bcc.out","w",stdout);
      init();
      printG(); 
     //dfnlow(3,-1);
      bicon(3,-1);
      printDfnLow();
//      getchar(); 
 }
Пример #8
0
void printavl(node *tree)
{int d;
for(d=1;d<=height+1;d++)
{

printG(tree,d);

}
}
Пример #9
0
bool IDtest(std::string is, std::string target) {
  std::stringstream ss;
  ss << "ID: is '" << is << "', should be '" << target << "'\n";
  if (is == target)
    printG(ss.str());
  else
    printR(ss.str());
  return is == target;
}
Пример #10
0
void printGameOver(int x, int y) {
	printG(x,y);
	printA(x+5*SIZE+GAP, y);
	printM(x+8*SIZE+2*GAP, y);
	printE(x+13*SIZE+3*GAP, y);
	printO(x+16*SIZE+5*GAP, y);
	printV(x+20*SIZE+6*GAP, y);
	printE(x+24*SIZE+7*GAP, y);
	printR(x+27*SIZE+8*GAP, y);
}
Пример #11
0
//_______________________________________________________________________________________________________
int main(int argc, char** argv) {
  parseArgs(argc, argv);

  printf("\n");
  printY("[TEST] Test conditions:\n");
  if (m_start_dsp)
    printG("\tDisplay\n");
  else
    printR("\tDisplay\n");

  if (m_start_imu)
    printG("\tIMU\n");
  else
    printR("\tIMU\n");

  if (m_start_imu && m_start_env)
    printG("\tEnvSens\n");
  else if (m_start_imu && !m_start_env)
    printR("\tEnvSens\n");
  else if (!m_start_imu && m_start_env)
    printR("\tskipping EnvSens (IMU needs to be enabled!)\n");
  else
    printR("\tEnvSens\n");

  if (m_start_ldc)
    printG("\tLDC\n");
  else
    printR("\tLDC\n");

  if (m_start_bat)
    printG("\tBatGauge\n");
  else
    printR("\tBatGauge\n");

  printf("\n");
  printY("[TEST] Init devices...\n");
  printf("\n");
  fflush(stdout);


  // Set up display
  if (m_start_dsp)
    m_dsp = new display_edison(m_dsp_resolution, m_dsp_hands);

  // Set up IMU
  if (m_start_imu) {
    m_imu = new imu_edison(m_i2c_bus, m_mpu_address, m_start_env);
    m_imu->setupIMU();
  }

  // Set up LDC
  if (m_start_ldc)
    m_ldc = new ldc_edison(m_i2c_bus);

  // Start battery gauge
  if (m_start_bat) {
    m_bat = new batgauge_edison(m_i2c_bus);
    m_bat->setAlertThreshold(m_alert_threshold);
  }

  printf("\n");

  usleep(1000000);


  // start testing
  bool success = true;

  // test display
  if (m_start_dsp) {
    printY("[TEST] Drawing clock on display...\n");
    printf("\n");

    m_dsp->clear();
    m_dsp->analogClock(true);
    m_dsp->flush();
  }

  // test IMU
  if (m_start_imu) {
    printY("[TEST] Testing IMU...\n");

    printf("IMU ");
    if (!IDtest(m_imu->getID(), m_imu_ID))
      success = false;
    printf("MAG ");
    if (!IDtest(m_imu->getMagID(), m_mag_ID))
      success = false;

    if (!m_idonly) {
      std::vector<float> data = m_imu->toReadable(m_imu->readRawIMU());
      float mx, my, mz;
      m_imu->getCompassData(mx, my, mz);

      printf("Temperature [DegC]:\n\t%f\n", data[6]);
      printf("Accelerometer [m/s^2]:\n");
      printf("\tX: %f\n", data[0]);
      printf("\tY: %f\n", data[1]);
      printf("\tZ: %f\n", data[2]);
      printf("Gyroscope [deg/s]:\n");
      printf("\tX: %f\n", data[3]);
      printf("\tY: %f\n", data[4]);
      printf("\tZ: %f\n", data[5]);
      printf("Compass [mGs]:\n");
      printf("\tX: %f\n", mx);
      printf("\tY: %f\n", my);
      printf("\tZ: %f\n", mz);
    }
    printf("\n");
    fflush(stdout);
  }

  // test EnvSens
  if (m_start_imu && m_start_env) {
    printY("[TEST] Testing environmental sensor...\n");

    if (!IDtest(m_imu->getEnvID(), m_env_ID))
      success = false;

    if (!m_idonly) {
      float T, P, H;
      m_imu->getEnvData(T, P, H);

      printf("Temperature [DegC]: %f\n", T);
      printf("Pressure [hPa]: %f\n", P);
      printf("Humidity [%%RH]: %f\n", H);
    }
    printf("\n");
    fflush(stdout);
  }

  // test LDC
  if (m_start_ldc) {
    printY("[TEST] Testing LDC...\n");

    if (!IDtest(m_ldc->getVersion(), m_ldc_ID))
      success = false;

    if (!m_idonly) {
      std::vector<uint16_t> LDC(2, 0);
      LDC = m_ldc->getADC();

      printf("ADC0 (vis/IR) [raw]: %i\n", LDC[0]);
      printf("ADC1 (IR) [raw]: %i\n", LDC[1]);
    }
    printf("\n");
    fflush(stdout);
  }

  // test BatGauge
  if (m_start_bat) {
    printY("[TEST] Testing battery gauge...\n");

    if (!IDtest(m_bat->getVersion(), m_bat_ID))
      success = false;

    if (!m_idonly) {
      printf("Voltage: %fV\n", m_bat->getVCell());
      printf("State of Charge: %i%%\n", m_bat->getSoC());
      printf("Alert Threshold: %i%%\n", m_bat->getAlertThreshold());
    }
    printf("\n");
    fflush(stdout);
  }

  if (success)
    printG("[TEST] All ID tests successful.\n");
  else
    printR("[TEST] Some ID tests failed!\n");


  if (m_start_bat)
    delete m_bat;
  if (m_start_ldc)
    delete m_ldc;
  if (m_start_imu)
    delete m_imu;
  if (m_start_dsp)
    delete m_dsp;

  if (success)
    return 0;
  else
    return 1;
}