本文整理汇总了C++中readInput函数的典型用法代码示例。如果您正苦于以下问题:C++ readInput函数的具体用法?C++ readInput怎么用?C++ readInput使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readInput函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWidget
XyzWidget::XyzWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::XyzWidget)
{
ui->setupUi(this);
//rpy = readInput("/Users/utilisateur/Documents/Navia/GUI/XYZ/rpy.txt");
//xyz = readInput("/Users/utilisateur/Documents/Navia/GUI/XYZ/log_out.txt");
QString namerpy = QFileDialog::getOpenFileName(this, tr("Open RPY"),
"",
tr("Text files (*.txt)"));
QString namexyz = QFileDialog::getOpenFileName(this, tr("Open LOGOUT"),
"",
tr("Text files (*.txt)"));
rpy=readInput(namerpy);
xyz=readInput(namexyz);
//fenêtre XYZ
setupRealtimeData1(ui->customPlot1);
//fenêtre Vx Vy Vz
setupRealtimeData2(ui->customPlot2);
//febêtre ax ay az
setupRealtimeData3(ui->customPlot3);
//fenêtre R P Y
setupRealtimeData4(ui->customPlot4);
connect(&datatimer, SIGNAL(timeout()), this, SLOT(readResponseXYZ()));
datatimer.start(0); // Interval 0 means to refresh as fast as possible
}
示例2: evaluateExpressions
void evaluateExpressions() {
int degree = 1;
char *varName;
char *ar;
List tl, tl1;
double w;
printf("give an expression: ");
ar = readInput();
while (ar[0] != '!') {
tl = tokenList(ar);
printf("\nthe token list is ");
printList(tl);
tl1 = tl;
if ( valueExpression(&tl1,&w) && tl1==NULL ) {
/* there may be no tokens left */
printf("this is a numerical expression with value %g\n",w);
} else {
tl1 = tl;
if ( acceptExpression(&tl1, varName, °ree) && tl1 == NULL ) {
printf("this is an arithmetical expression\n");
} else {
printf("this is not an expression\n");
}
}
free(ar);
freeTokenList(tl);
printf("\ngive an expression: ");
ar = readInput();
}
free(ar);
printf("good bye\n");
}
示例3: process_file
int process_file(char *batch_file)
{
FILE * batch_stream;
char *cmdLine;
READ_STATUS s;
batch_stream = fopen(batch_file, "r");
if (batch_stream == NULL) {
printError();
return 1;
}
for (s = readInput(batch_stream, &cmdLine);
(s != INPUT_READ_EOF) && (s != INPUT_READ_ERROR);
s = readInput(batch_stream, &cmdLine)) {
if (s == INPUT_READ_OVERFLOW) {
display_full_command(cmdLine);
free(cmdLine);
continue;
}
run_cmd(cmdLine, BATCH_MODE);
}
fclose(batch_stream);
return 0;
}
示例4: main
int main(int argc, char** argv)
{
int grid_rows = 0, grid_cols = 0, iterations = 0;
float *MatrixTemp = NULL, *MatrixPower = NULL;
char tfile[] = "temp.dat";
char pfile[] = "power.dat";
char ofile[] = "output.dat";
if (argc >= 3) {
grid_rows = atoi(argv[1]);
grid_cols = atoi(argv[1]);
iterations = atoi(argv[2]);
if (argc >= 4) setenv("BLOCKSIZE", argv[3], 1);
if (argc >= 5) {
setenv("HEIGHT", argv[4], 1);
pyramid_height = atoi(argv[4]);
}
} else {
printf("Usage: hotspot grid_rows_and_cols iterations [blocksize]\n");
return 0;
}
// Read the power grid, which is read-only.
int num_elements = grid_rows * grid_cols;
MatrixPower = new float[num_elements];
readInput(MatrixPower, grid_rows, grid_cols, pfile);
// Read the temperature grid, which will change over time.
MatrixTemp = new float[num_elements];
readInput(MatrixTemp, grid_rows, grid_cols, tfile);
float grid_width = chip_width / grid_cols;
float grid_height = chip_height / grid_rows;
float Cap = FACTOR_CHIP * SPEC_HEAT_SI * t_chip * grid_width * grid_height;
// TODO: Invert Rx, Ry, Rz?
float Rx = grid_width / (2.0 * K_SI * t_chip * grid_height);
float Ry = grid_height / (2.0 * K_SI * t_chip * grid_width);
float Rz = t_chip / (K_SI * grid_height * grid_width);
float max_slope = MAX_PD / (FACTOR_CHIP * t_chip * SPEC_HEAT_SI);
float step = PRECISION / max_slope;
float step_div_Cap = step / Cap;
struct timeval starttime, endtime;
long usec;
runOMPHotspotSetData(MatrixPower, num_elements);
gettimeofday(&starttime, NULL);
runOMPHotspot(MatrixTemp, grid_cols, grid_rows, iterations, pyramid_height,
step_div_Cap, Rx, Ry, Rz);
gettimeofday(&endtime, NULL);
usec = ((endtime.tv_sec - starttime.tv_sec) * 1000000 +
(endtime.tv_usec - starttime.tv_usec));
printf("Total time=%ld\n", usec);
writeOutput(MatrixTemp, grid_rows, grid_cols, ofile);
delete [] MatrixTemp;
delete [] MatrixPower;
return 0;
}
示例5: main
int main(){
char * num1 ;
char * num2 ;
num1 = readInput(1);
num2 = readInput(2);
printf("\nConverted to int:%d",convert_to_int(num1));
printf("\nConverted to char:%s",convert_to_char(convert_to_int(num1)));
printf("\nMax:%d",max(num1,num2,10));
printf("\nSplit at 0-3:%s",split_at(num1,0,3));
printf("\nSplit at 3-5:%s",split_at(num1,3,strlen(num1)));
printf("\nKaratsuba:%d",karatSuba(num1,num2));
return 0 ;
}
示例6: init
// Initialization. Models, textures, program input and graphics definitions
void init (void)
{
glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
// Model loading based on each scale
model1 = readModel (model1Path, model1Scale);
model1 -> size = model1Size;
model2 = readModel (model2Path, model2Scale);
model2 -> size = model2Size;
// Textures configuration in general
configTextMode();
// Read the program input (not user input) to determinw hoe many rooms
// and theirs objects will be drawn
readInput();
// Light. The light switch is made in the input.cpp.
// Switch it pressing the key L. Do it!
if (light)
{
GLfloat light_position[] = {1.0, 1.0, 1.0, 0.0};
GLfloat light_diffuse[] = {0.9, 0.9, 0.9, 0.0};
GLfloat light_ambient[] = {1.4, 1.4, 1.4, 0.0};
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
}
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
}
示例7: readInput
void Ghdb::prompt ( void ) {
int ret = GHDB_OK ;
ret = readInput ( "ghdb", 0 ) ;
if ( ret ) {
return ;
}
//Input string
std::string textInput = _cmdBuffer ;
//Split the inputing sentence.
std::vector<std::string> textVec ;
split ( textInput, SPACE, textVec ) ;
int count = 0 ;
std::string cmd = "" ;
std::vector<std::string> optionVec ;
std::vector<std::string>::iterator iter = textVec.begin() ;
//handle different command here.
ICommand* pCmd = NULL ;
for ( ; iter != textVec.end(); ++iter ) {
std::string str = *iter ;
if ( 0 == count ) {
cmd = str ;
count ++ ;
} else {
optionVec.push_back(str) ;
}
}
pCmd = _cmdFactory.getCommandProcessor ( cmd.c_str() ) ;
if ( NULL != pCmd ) {
pCmd -> execute ( _sock, optionVec ) ;
}
}
示例8: Init_Problem_1
void Init_Problem_1 ( )
//======================================================================
// XZones = 2, YZones = 1, ZZones = 2, ALL hexahedra
{
FILE *inputDeck;
char fileName[100];
strcpy(fileName,"problem1.cmg");
/* printf("using input deck: %s\n",fileName); */
/*Open the file to parse */
inputDeck = fopen(fileName, "r");
/*print the prompt*/
CMGDPRINT("CMG > ");
readInput(inputDeck);
int success = fclose(inputDeck);
bcastinp( );
cgenmesh();
/* printf("CMG initialization completed for ==========> PROBLEM # 1\n"); */
}
示例9: Init_CMG_Problem_From_File
void Init_CMG_Problem_From_File (const char* meshFile)
//======================================================================
{
FILE *inputDeck;
char fileName[100];
strcpy(fileName,meshFile);
/* printf("using input deck: %s\n",fileName); */
/*Open the file to parse */
inputDeck = fopen(fileName, "r");
/*print the prompt*/
CMGDPRINT("CMG > ");
readInput(inputDeck);
int success = fclose(inputDeck);
bcastinp( );
cgenmesh();
/* printf("CMG initialization completed for ==========> PROBLEM # 1\n"); */
}
示例10: main
//stores the input image, resizes with seam carving, and generates the output image
int main(int argc, char *argv[]) {
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (!readInput(argv[1])) {
MPI_Abort(MPI_COMM_WORLD, 1);
}
//get the output width and height
target_width = atoi(argv[3]);
target_height = atoi(argv[4]);
//exit if the output dimensions are larger than the input image dimensions
if (initial_width < target_width || initial_height < target_height) {
printf("Error: Desired output image dimensions larger than input image dimensions.\n");
MPI_Abort(MPI_COMM_WORLD, 1);
}
image_energy = (double *) malloc(initial_width * initial_height * sizeof(double));
path_costs = (double *) malloc(initial_width * initial_height * sizeof(double));
previous_x = (int *) malloc(initial_width * initial_height * sizeof(int));
previous_y = (int *) malloc(initial_width * initial_height * sizeof(int));
n = initial_width * initial_height;
if (image_energy == NULL || path_costs == NULL || previous_x == NULL || previous_y == NULL) {
printf("problem");
}
assignPixels();
//remove vertical seams until reaching the target width
while (current_width > target_width) {
//calculate the energy of the image
computeImageEnergy();
//remove the seam
removeVerticalSeam();
}
//remove horizontal seams until reaching the target height
while (current_height > target_height) {
//calculate the energy of the image
computeImageEnergy();
//remove the seam
removeHorizontalSeam();
}
if (rank == 0) {
outputCarved(argv[2]);
}
free(image_energy);
free(path_costs);
free(previous_x);
free(previous_y);
MPI_Finalize();
return 0;
}
示例11: readInput
Device2D Run2D::createDevice2D(int argc, char** argv) {
std::map<std::string, Material> matLib = readInput(argc, argv);
std::vector<Device1D> dev1DList;
Device2D dev2D;
int accu = 0; // accumalated layer num
// construct all device1D
for (int i = 0; i < io2D.blockNum; i++) { // for each block
dev1DList.push_back(createDevice1D(io2D, matLib, accu, i));
accu = accu + io2D.layerNumList[i]; // update accu
}
std::cout << " **** dev1DList is completed with size = " << dev1DList.size() << std::endl;
// construct device2D
dev2D.startWith_2D(dev1DList[0], io2D.blockLength[0], io2D.blockPoint[0], io2D.leftBT);
for (int i = 1; i < io2D.blockNum -1; i++) {
dev2D.add_2D(dev1DList[i], io2D.blockLength[i], io2D.blockPoint[i]);
}
dev2D.endWith_2D(dev1DList[io2D.blockNum - 1], io2D.blockLength[io2D.blockNum - 1],
io2D.blockPoint[io2D.blockNum - 1], io2D.rightBT);
dev2D.matrixDiff_2D();
std::cout << " **** Device2D is completed." << std::endl;
return ( dev2D );
}
示例12: main
int main(int argc, char *argv[]) {
FILE* input = NULL;
Queue *source = initq();
int option;
while ((option = getopt(argc, argv, "hv")) != EOF) {
switch (option) {
case 'h':
usage();
break;
case 'v':
printf("bf version %s\nCopyright (c) %s, %s\nX11 license\n", VERSION, YEAR, AUTHOR);
exit(0);
break;
default:
usage();
break;
}
}
if (argv[optind] == NULL)
usage();
else if ((input = fopen(argv[1], "r")) == NULL) {
error(NO_FILE, "main");
} else {
readInput(input, source);
fclose(input);
execute(source);
delq(source);
}
return 0;
}
示例13: simulate
void simulate()
{
printf("Blood bank inventory management simulation.\n");
if ((infile = fopen("bloodbank.in", "r")) == NULL) {
printf("Can't find the file: bloodbank.in\n");
exit(1);
}
if ((outfile = fopen("bloodbank.out", "w")) == NULL) {
printf("Can't create the file: bloodbank.out\n");
exit(1);
}
readInput();
init_simlib();
// Schedule first event
event_schedule(sim_time + 0, EVENT_BLOOD_ARRIVAL); //first arrival from camp at beginning
event_schedule(sim_time + 0, EVENT_BLOOD_DONATION); //first donation at beginning
event_schedule(sim_time + 1, EVENT_BLOOD_DEMAND); //first demand next day
event_schedule(max_sim_time, EVENT_END_SIMULATION);
eventLoop();
report();
fclose(infile);
fclose(outfile);
}
示例14: main
int main(void){
int arr[2];
readInput(arr);
printf(" loop x^y : %d \n", powerLoop(arr[0],arr[1]));
printf(" recursive: %d \n", powerRecursive(arr[0],arr[1]));
return 0;
}
示例15: sanitize
//////////////////////////////////////////////////////////////////////////////
///
/// Read the input stream
///
//////////////////////////////////////////////////////////////////////////////
void controller::readInputStream(unsigned char* ptr) {
int position;
sanitize(ptr, &position);
bool isOverflow = false;
// Validate input stream
while (!isValidCommand(ptr) || isDividedByZeroDetected(ptr)) {
// Prevent to have a string with no operation or with invalid operands
if (isLFDetected(ptr)
&& (!isOperationDetected(ptr) || !isOperand1Detected(ptr)
|| !isOperand2Detected(ptr))) {
sanitize(ptr, &position);
displayMessage((char*) "Invalid input string\n");
isOverflow = false;
}
if (isDividedByZeroDetected(ptr)) {
sanitize(ptr, &position);
displayMessage((char*) "Division by zero detected\n");
isOverflow = false;
}
ptr[position++] = (unsigned char) readInput();
// Loop in array
if (position == 20) {
sanitize(ptr, &position);
if (!isOverflow)
displayMessage((char*) "String too long, try again\n");
isOverflow = true;
}
}
}