Example #1
0
int main(int argc, char **argv)
{
    setlocale(0, "Russian");
    ifstream In = ifstream("input.txt");

    if(!In.is_open())
    {
        printf_s("Нет файла :(\n");
        return -1;
    }

    Sphere s1 = ReadSphere(In);
    Sphere s2 = ReadSphere(In);

    In.close();

    PrintSphere(s1,1);
    PrintSphere(s2,2);

    ofstream Out = ofstream("output.txt");
    if(IsSphereContect(s1,s2))
    {
        Out<<"YES";
        printf("Сферы пересикаются\n");
    } else {
        Out<<"NO";
        printf("Сферы не пересикаются\n");
    }

    Out.close();
    return EXIT_SUCCESS;
}
Example #2
0
Counter::Counter(string fileName, size_t readerRank, size_t readerSize)
  : _fn{fileName}
  , _offset{0}
  , _length{0}
  , _fileSize{0}
{
  auto&& tmp = ifstream(_fn);
  tmp.seekg(0, ios_base::end);
  _fileSize = tmp.tellg();

  auto minReading = _fileSize / readerSize;
  
  auto rest = _fileSize - minReading * readerSize;

  auto offsets = vector<size_t>{};
  auto lengths = vector<size_t>{};
  auto curOffset = 0u;

  for(auto i = 0u; i < readerSize; ++i)
    {
      offsets.push_back(curOffset);
      lengths.push_back( minReading + (i  <  rest ? 1 : 0  ) );
      curOffset += lengths.back();
    }

  _offset = offsets.at(readerRank);
  _length = lengths.at(readerRank);
  
  std::fill(_counts, _counts + 256, 0u );
  
  // cout << "thread " << readerRank << " / " << readerSize << " reading at offset " << _offset << " for length " << _length << endl; 
}
Example #3
0
bool Image::load(RenderDevice* device, const String& imageFile)
{
	using std::ifstream;
	using std::ios;

	rc::ResourceLoader loader;

	tsinfo("Loading image: \"%\"", imageFile);

	loader.load(ifstream(imageFile, ios::binary));

	if (loader.fail())
	{
		tswarn("Unable to load image.");
		return !setError(true);
	}

	const auto& imgReader = loader.deserialize<tsr::Image>();

	const uint32 sign = imgReader.signature();
	tsassert(memcmp("TSTX", reinterpret_cast<const char*>(&sign), 4) == 0);

	ImageResourceInfo info;
	ResourceData data;

	data.memoryByteDepth = imgReader.byteDepth();
	data.memoryByteWidth = imgReader.byteWidth();
	data.memory = imgReader.data().data();

	info.format = (ImageFormat)imgReader.format();
	info.type = (ImageType)imgReader.type();
	info.usage = ImageUsage::SRV;
	info.height = imgReader.height();
	info.width = imgReader.width();
	info.length = imgReader.length();
	info.useMips = true;
	info.mipLevels = 1;
	info.msLevels = 1;

	//Create image resource
	m_img = device->createResourceImage(&data, info, m_img.release());

	if (!m_img)
	{
		tserror("Unable to create image.");
		return !setError(true);
	}

	//Save image info
	m_imgInfo = info;

	return !setError(false);
}
Example #4
0
bool FileExists(const char* Archivo){
	if(!ifstream(Archivo)){
		ofstream crear(Archivo);
		ofstream write;
		write.open(Archivo);
		write<<"Falso,0";
		write.close();
		crear.close();
		return true;
	}else{
		return true;
	}
		
}
Example #5
0
void Counter::count()
{
  auto&& in = ifstream(_fn);
  in.seekg(_offset, ios_base::beg);
  
  auto numRead = 0u;
  while(numRead  < _length )
    {
      char c ;  
      in.get(c);
      ++_counts[static_cast<size_t>(c)];
      ++numRead; 
    }
}