Ejemplo n.º 1
0
void transPrint(char *p, int j){
  int i = j;
  if (*p != '\0' && *p > '0' && *p <= '9'){
    char c = *p;
    fakePrint(CHAR2CHAR(c), i++);
    transPrint(p+1, i);
  } else if (*p == '\0'){
    fakePrint('\0', i);
    printf("%s\n", gPrintBuffer);
    return;
  } else {
    return;
  }

  i = j;
  if (*(p+1) != '\0' && *(p+1) >= '0' && *(p+1) <= '9'){
    char c = *p;
    char cn = *(p+1);
    int doubleC = CHAR2INT(c) * 10 + CHAR2INT(cn);
    if (doubleC <= 26){
      fakePrint(INT2CHAR(doubleC), i++);
      transPrint(p+2, i);
    }
  }
  return;
  
}
Ejemplo n.º 2
0
int main( int argc, char *argv[] ) {
  
  int strip = atoi(argv[1]);
  int disk =  atoi(argv[2]);
  int lba =   atoi(argv[3]);
  int size =  atoi(argv[4]);
  short startFound = 0;
  int diskIndex = 0;
  int stripIndex = 0;
  int i;
  int multiple = 0;
  int blockIndex = 0;
  //loop until address reached
  for(i = 0; i < size + lba; i++){
    if(i == lba){
      startFound = 1;
    }
    if(startFound == 1){
      fakePrint(diskIndex, blockIndex);
    }
    //printf("%4d: [%d,%d,%d]\n", i, diskIndex, stripIndex, blockIndex);
    //if reached end of strip change disk
    if((strip-1) == stripIndex){
      //if reached last disk move back to disk 0
      if(diskIndex == (disk-1)){
        diskIndex = 0;
        multiple += strip;
        stripIndex = 0;
      }
      //not the last disk
      else {
        //blockIndex = multiple;
        diskIndex++;
        stripIndex = 0;
      }
      blockIndex = multiple; //reset to block to strip multiple
      
    }
    else {
      blockIndex++;
      stripIndex++;
    }
    
  }
  diskIndex = diskIndex % disk;
  
  //printf("[disk,block]: [%d,%d]\n", diskIndex, blockIndex);
  return 0;
}