void Output::printPaddedSci(double message, int width, PrintAlign align, int prec) { if (!_streams[_curStream].print()) return; int order = (int)floor(log10(fabs(message))); int places = prec; if (places == -1) { double temp = message / pow(10.0, order); for (places = 0; places <= 8; places++) { if ((temp - roundToOne(temp) > -1e-9) && (temp - roundToOne(temp) < 1e-9)) break; temp *= 10; } } streamsize origPrec = stream().precision(); if (align == LEFT) stream() << resetiosflags(ios::right) << setiosflags(ios::left); stream() << setiosflags(ios::scientific) << setprecision(places); stream() << setw(width) << checkZero(message, abs(order) + places); stream() << resetiosflags(ios::scientific) << setprecision(origPrec) << flush; if (align == LEFT) stream() << resetiosflags(ios::left) << setiosflags(ios::right); }
void float_thread_t::run() { float result; register float r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18, r19, r20, r21, r22, r23, r24, r25, r26, r27, r28, r29, r30, r31; r1 = (float) id; r2 = (float) id; r3 = (float) id; r4 = (float) id; r5 = (float) id; r6 = (float) id; r7 = (float) id; r8 = (float) id; r9 = (float) id; r10 = (float) id; r11 = (float) id; r12 = (float) id; r13 = (float) id; r14 = (float) id; r15= (float) id; r16= (float) id; r17= (float) id; r18= (float) id; r19= (float) id; r20 = (float) id; r21 = (float) id; r22 = (float) id; r23 = (float) id; r24 = (float) id; r25 = (float) id; r26 = (float) id; r27 = (float) id; r28 = (float) id; r29 = (float) id; r30 = (float) id; r31 = (float) id; result = r1+ r2+ r3+ r4+ r5+ r6+ r7+ r8+ r9+ r10+ r11+ r12+ r13+ r14+ r15+ r16+ r17+ r18+ r19+ r20+ r21+ r22+ r23+ r24+ r25+ r26+ r27+ r28+ r29+ r30+ r31; SAFE_IO ( "Hello, world from " << id << ", result = " << setprecision(6) << setiosflags(ios::fixed) << result << resetiosflags(ios::fixed) << ", check = " << 31 * id << endl ) sthread_t::yield(); result = r1+ r2+ r3+ r4+ r5+ r6+ r7+ r8+ r9+ r10+ r11+ r12+ r13+ r14+ r15+ r16+ r17+ r18+ r19+ r20+ r21+ r22+ r23+ r24+ r25+ r26+ r27+ r28+ r29+ r30+ r31; SAFE_IO( "Hello, world from " << id << ", result = " << setprecision(6) << setiosflags(ios::fixed) << result << resetiosflags(ios::fixed) << ", check = " << 31 * id << endl;)
void MetaNumeric::print(ostream& stream) { stream << resetiosflags(stream.flags()); stream << setfill(' '); if (!numeric) { stream << " '" << actual_name << "' : non-numeric values are present or all values are missing" << endl; } else { stream << resetiosflags(stream.flags()); stream << setprecision(7); stream << setw(12) << left << " N" << " = " << n << endl; stream << setw(12) << left << " Mean" << " = " << mean << endl; stream << setw(12) << left << " StdDev" << " = " << sd << endl; if (print_min == true) { stream << setw(12) << left << " Min" << " = " << min << endl; } if (print_max == true) { stream << setw(12) << left << " Max" << " = " << max << endl; } if (print_median == true) { stream << setw(12) << left << " Median" << " = " << median << endl; } if (print_skewness == true) { stream << setw(12) << left << " Skewness" << " = " << skew << endl; } if (print_kurtosis == true) { stream << setw(12) << left << " Kurtosis" << " = " << kurtosis << endl; } stream << setw(12) << left << " No. of NAs" << " = " << na << endl; if (print_quantiles == true) { stream << endl; stream << " Quantiles:" << endl; stream << fixed; stream << setprecision(0); stream << " Min (" << quantiles[0][0] * 100 << "%)"; stream << "\t = " << setprecision(3) << quantiles[0][1] << endl; for (unsigned int j = 1; j < 4; j++) { stream << setprecision(0); stream << " " << quantiles[j][0] * 100 << "%"; stream << "\t\t = " << setprecision(3) << quantiles[j][1] << endl; } stream << setprecision(0); stream << " Median (" << quantiles[4][0] * 100 << "%)"; stream << "\t = " << setprecision(3) << quantiles[4][1] << endl; for (unsigned int j = 5; j < 8; j++) { stream << setprecision(0); stream << " " << quantiles[j][0] * 100 << "%"; stream << "\t\t = " << setprecision(3) << quantiles[j][1] << endl; } stream << setprecision(0); stream << " Max (" << quantiles[8][0] * 100 << "%)"; stream << "\t = " << setprecision(3) << quantiles[8][1] << endl; } stream << resetiosflags(stream.flags()); stream << setfill(' '); } }
void Output::printPadded(int message, int width, PrintAlign align) { if (!_streams[_curStream].print()) return; if (align == LEFT) stream() << resetiosflags(ios::right) << setiosflags(ios::left); stream() << setw(width) << message << flush; if (align == LEFT) stream() << resetiosflags(ios::left) << setiosflags(ios::right); }
void MessageEditor::refresh_character_count() { SetConsoleCursorPosition(stdout_handle, input_num_pos); if (character_count > 140) { SetConsoleTextAttribute(stdout_handle, FOREGROUND_RED | FOREGROUND_INTENSITY); cout << setiosflags(ios::right) << setw(3) << character_count << resetiosflags(ios::right); SetConsoleTextAttribute(stdout_handle, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED); } else cout << setiosflags(ios::right) << setw(3) << character_count << resetiosflags(ios::right); }
void Streckenende::vBearbeiten(void) { cout << "STRECKENENDE " << endl << (*p_pFahrzeug) << endl << (*p_pWeg) << endl << endl; p_pWeg->vAbgabe(p_pFahrzeug); Kreuzung* pZielKreuzung = p_pWeg->vGetZiel(); Weg* pNeuerWeg = pZielKreuzung->ptZufaelligerWeg(p_pWeg); pZielKreuzung->vAnnahme(p_pFahrzeug, 0, pNeuerWeg); cout << setiosflags(ios::fixed) << setprecision(2) << setiosflags(ios::left); cout << endl << setw(11) << "ZEIT" << ": " << dGlobaleZeit << endl; cout << setw(11) << "KREUZUNG" << ": " << pZielKreuzung->getName() << " " << pZielKreuzung->dGetTankstelle() << endl; cout << setw(11) << "WECHSEL" << ": " << p_pWeg->getName() << " -> " << pNeuerWeg->getName() << endl; cout << (*p_pFahrzeug) << endl << endl; cout << resetiosflags(ios::fixed) << resetiosflags(ios::left); }
static void printMetricsUti(double cpu_time, double gpu_time, double gpu_full_time, double speedup, double fullspeedup, std::stringstream& stream, std::stringstream& cur_subtest_description) { //cout <<TAB<< setw(7) << stream.str(); cout <<TAB; stream.str(""); stream << cpu_time; cout << setw(10) << stream.str(); stream.str(""); stream << gpu_time; cout << setw(10) << stream.str(); stream.str(""); stream << "x" << setprecision(3) << speedup; cout << setw(8) << stream.str(); stream.str(""); stream << gpu_full_time; cout << setw(10) << stream.str(); stream.str(""); stream << "x" << setprecision(3) << fullspeedup; cout << setw(10) << stream.str(); cout << cur_subtest_description.str(); cout << resetiosflags(ios_base::left) << endl; }
static void dumpAttributes(MDICOMWrapper& w, tagVector& v, ostream& o) { tagVector::iterator i = v.begin(); while (i != v.end()) { DCM_TAG t = *i; U16 group = DCM_TAG_GROUP(t); U16 element = DCM_TAG_ELEMENT(t); DCM_ELEMENT e; ::memset(&e, 0, sizeof(e)); e.tag = t; CONDITION cond = ::DCM_LookupElement(&e); if (cond != DCM_NORMAL) { ::COND_PopCondition(TRUE); e.description[0] = '\0'; } o << hex << setw(4) << setfill ('0') << group << " " << hex << setw(4) << element; o << setw (40) << setfill (' ') << e.description << ": "; MString s = w.getString(t); o << resetiosflags(0); o << s; o << endl; i++; } }
void Library::showUsers(string search) const { IdentNum i; User userTemp; vector <IdentNum> usersFound; for (i=1;i<=users.size();i++) { userTemp=getUserByID(i); string userName = userTemp.getName(); size_t counter = 0; // conta as vezes seguidas que detecta chars iguais bool found = false; // quando counter for igual a search.size() found = true for (size_t k = 0; k < userName.size() && !found; ++k) { if (counter < search.size()) { char temp1 = toupper(search[counter]); char temp2 = toupper(userName[k]); if (temp1 == temp2) if (temp1 == ' ') if (counter > 0) counter++; else counter = 0; else counter++; else counter = 0; } if (counter == search.size()) { found = true; } } if (found) usersFound.push_back(userTemp.getID()); } if (usersFound.size()==0) cout << "Nao foi encontrado nenhum utilizador com esses termos.\n"; else { cout << "#### Utilizadores ####\n"; cout << "--------------------------------------------------------------- \n"; cout << "| ID | Nome | Activo |\n"; cout << "--------------------------------------------------------------- \n"; cout << setiosflags(ios::left); for(size_t k = 0;k<usersFound.size();k++) { i = usersFound[k]; User userTemp=getUserByID(i); cout << "| " << setw(MAXIDLENGTH) << userTemp.getID() << "| " << setw(MAXNAMELENGTH) << userTemp.getName() << "| "; if (userTemp.isActive()) cout << setw(8) << "Sim" << "|\n"; else cout << setw(8) << "Nao" << "|\n"; } cout << resetiosflags(ios::left); cout << "--------------------------------------------------------------- \n"; } }
void Library::showBooks(string search, int option) const { IdentNum i; vector <IdentNum> booksFound; for (i=1;i<=books.size();i++) { string searchString; Book bookTemp=getBookByID(i); if(option==0) searchString = bookTemp.getAuthor(); else searchString = bookTemp.getTitle(); size_t counter = 0; // conta as vezes seguidas que detecta chars iguais bool found = false; // quando counter for igual a search.size() found = true for (size_t k = 0; k < searchString.size() && !found; ++k) { if (counter < search.size()) { char temp1 = toupper(search[counter]); char temp2 = toupper(searchString[k]); if (temp1 == temp2) if (temp1 == ' ') if (counter > 0) counter++; else counter = 0; else counter++; else counter = 0; } if (counter == search.size()) { found = true; } } if (found) booksFound.push_back(bookTemp.getID()); } if (booksFound.size()==0) cout << "\nNao foi encontrado nenhum livro com esses termos.\n"; else { cout << "\n#### Livros ####\n"; cout << "----------------------------------------------------------------------------\n"; cout << "| ID | Titulo | Autor | Disp. |\n"; cout << "----------------------------------------------------------------------------\n"; cout << setiosflags(ios::left); for(size_t k = 0;k<booksFound.size();k++) { i = booksFound[k]; Book bookTemp=getBookByID(i); cout << "| " << setw(MAXIDLENGTH) << bookTemp.getID() << "| " << setw(MAXTITLELENGTH) << bookTemp.getTitle() << "| " << setw(MAXAUTHORLENGTH) << bookTemp.getAuthor() << "| " << setw(MAXQUANTITYLENGTH) << bookTemp.getNumAvailable() << "|\n"; } cout << resetiosflags(ios::left); cout << "----------------------------------------------------------------------------\n"; } }
void OutputResultOperations(const char *name, const char *operation, bool pc, unsigned long iterations, double timeTaken) { cout << "<TR><TH>" << name << " " << operation << (pc ? " with precomputation" : ""); cout << "<TD>" << iterations; cout << setiosflags(ios::fixed); cout << "<TD>" << setprecision(3) << timeTaken; cout << "<TD>" << setprecision(2) << (1000*timeTaken/iterations) << endl; cout << resetiosflags(ios::fixed); logtotal += log(iterations/timeTaken); logcount++; }
void Analysis(selist *analy,LinkQueue hword)//分析函数 { stack anasta; anasta.base=anasta.top=NULL; push(anasta,'#'); push(anasta,'Q'); string str; input(str,hword);// cout<<str<<" 输入串建立成功!"<<endl; cout<<"分析开始:"<<endl<<endl; int i=0; while(str[i]) { //int length=str.length(); disStack(anasta); cout<<"\t"; cout<<resetiosflags(ios_base::right)<<&str[i]; char ch=pop(anasta); if(ch==str[i]) { cout<<" "<<str[i]<<" 匹配"<<endl; ++i; } else { string s1(1,ch); string s2(1,str[i]); s1.append(s2); selist *p=analy; while(p) { if(p->Vn==s1) break; p=p->next; } cout<<" "<<p->Vt<<endl; if(p->Vt[3]=='$') continue; int lengh=p->Vt.length(); while(--lengh!=2) { push(anasta,p->Vt[lengh]); } } } cout<<endl<<"分析完毕!"<<endl; system("pause"); }
void OutputResultBytes(const char *name, unsigned long length, double timeTaken) { double mbs = length / timeTaken / (1024*1024); cout << "<TR><TH>" << name; cout << "<TD>" << length; cout << setiosflags(ios::fixed); cout << "<TD>" << setprecision(3) << timeTaken; cout << "<TD>" << setprecision(3) << mbs << endl; cout << resetiosflags(ios::fixed); logtotal += log(mbs); logcount++; }
std::string Bunny::FormatedDetails() const{ std::string strColor = Res::strColourList[static_cast<int>(m_Color)]; std::ostringstream ss; ss << setiosflags(std::ios::left) << std::setw(10) << m_strFirstName << " " << std::setw(10) << m_strLastName << ":" << std::setw(1) << (m_Features&IsFemale?"F":"M") << ":" << std::setw(7) << strColor << ":" << resetiosflags(std::ios::left) << std::setw(2) << std::dec << m_Age << ":" << (m_Features&IsMutant? "->0<-":""); return ss.str(); }
void output_global_angle(vector<aa> w) { int i; ofstream new_pdb("1a04.global",ios::out|ios::app); for(i=0;i<w.size();i++) { if(w[i].global_angle>0) { new_pdb<<resetiosflags(ios::adjustfield)<<setiosflags(ios::left)<<setw(5)<<w[i].res_num <<setw(4)<<w[i].res_id <<setw(1)<<w[i].chain_type; new_pdb<<resetiosflags(ios::adjustfield)<<setiosflags(ios::right)<<setw(4) <<setiosflags(ios::fixed) <<setprecision(3)<<setw(12)<<w[i].global_angle <<endl; } }//end of for(i=0 }
void Output::printPadded(double message, int width, PrintAlign align, int prec) { if (!_streams[_curStream].print()) return; int places = prec; if (places == -1) { double temp = message; for (places = 0; places <= 8; places++) { if ((temp - roundToOne(temp) > -1e-9) && (temp - roundToOne(temp) < 1e-9)) break; temp *= 10; } } streamsize origPrec = stream().precision(); if (align == LEFT) stream() << resetiosflags(ios::right) << setiosflags(ios::left); stream() << setiosflags(ios::fixed) << setprecision(places) << setw(width) << checkZero(message, places); stream() << resetiosflags(ios::fixed) << setprecision(origPrec) << flush; if (align == LEFT) stream() << resetiosflags(ios::left) << setiosflags(ios::right); }
void OutputResultBytes(const char *name, double length, double timeTaken) { double mbs = length / timeTaken / (1024*1024); cout << "\n<TR><TH>" << name; // cout << "<TD>" << setprecision(3) << length / (1024*1024); cout << setiosflags(ios::fixed); // cout << "<TD>" << setprecision(3) << timeTaken; cout << "<TD>" << setprecision(0) << setiosflags(ios::fixed) << mbs; if (g_hertz) cout << "<TD>" << setprecision(1) << setiosflags(ios::fixed) << timeTaken * g_hertz / length; cout << resetiosflags(ios::fixed); logtotal += log(mbs); logcount++; }
// List all the entries void PhoneBook::listEntries() { if(namebook.empty()) { cout << "The phone book is empty." << endl; return; } multimap<Person, string>::iterator iter; cout << setiosflags(ios::left); // Left justify output for(iter = namebook.begin() ; iter != namebook.end() ; iter++) { cout << setw(30) << iter->first.getName() << setw(12) << iter->second << endl; } cout << resetiosflags(ios::right); // Right justify output }
int main (int argc, char **argv) { struct params p; processArgsBasler (argc, argv, p); VERBOSE = p.verbose; Basler *b = new Basler (&p); b->LoadFLUOR (); b->ComputeColumnDensity (); b->Fit2DGauss (); setINI_num (p.reportfile, "FLUORCPP", "offset", b->gaus2dfit[5] * b->GetNPixels ()); double nfit = b->gaus2dfit[4] * 3.14159 * b->gaus2dfit[1] * b->gaus2dfit[3]; double peakd = b->gaus2dfit[4] / (pow (M_PI * b->gaus2dfit[1] * b->gaus2dfit[3], 0.5)) / pow (p.magnif, 3); // cm^-3 setINI_num (p.reportfile, "FLUORCPP", "nfit", nfit); setINI_num (p.reportfile, "FLUORCPP", "peakd", peakd); setINI_num (p.reportfile, "FLUORCPP", "ax0w", b->gaus2dfit[1] * p.magnif); setINI_num (p.reportfile, "FLUORCPP", "ax1w", b->gaus2dfit[3] * p.magnif); setINI_num (p.reportfile, "FLUORCPP", "ax0w_err", b->gaus2dfit_err[1] * p.magnif); setINI_num (p.reportfile, "FLUORCPP", "ax1w_err", b->gaus2dfit_err[3] * p.magnif); setINI_num (p.reportfile, "FLUORCPP", "ax0c", b->abs_ci); setINI_num (p.reportfile, "FLUORCPP", "ax1c", b->abs_cj); cout << p. shotnum << " nfit = " << nfit << setprecision (3) << " , peakd = " << peakd << " , sizes = (" << b->gaus2dfit[1] * p. magnif << " +/- " << b->gaus2dfit_err[1] * p.magnif << "," << b->gaus2dfit[3] * p.magnif << " +/- " << b->gaus2dfit_err[3] * p. magnif << ") , center = (" << setiosflags (ios:: fixed) << setprecision (0) << b->abs_ci << "," << b->abs_cj << ")" << endl; cout << resetiosflags (ios::fixed) << setprecision (6); // f->ComputeRadialAxialDensity (); return EXIT_SUCCESS; }
void TestSystem::printSummary() { cout << setiosflags(ios_base::fixed); cout << "\naverage GPU speedup: x" << setprecision(3) << speedup_total_ / std::max(1, num_subtests_called_) << endl; cout << "\nGPU exceeded: " << setprecision(3) << speedup_faster_count_ << "\nGPU passed: " << setprecision(3) << speedup_equal_count_ << "\nGPU failed: " << setprecision(3) << speedup_slower_count_ << endl; cout << "\nGPU exceeded rate: " << setprecision(3) << (float)speedup_faster_count_ / std::max(1, num_subtests_called_) * 100 << "%" << "\nGPU passed rate: " << setprecision(3) << (float)speedup_equal_count_ / std::max(1, num_subtests_called_) * 100 << "%" << "\nGPU failed rate: " << setprecision(3) << (float)speedup_slower_count_ / std::max(1, num_subtests_called_) * 100 << "%" << endl; cout << "\naverage GPUTOTAL speedup: x" << setprecision(3) << speedup_full_total_ / std::max(1, num_subtests_called_) << endl; cout << "\nGPUTOTAL exceeded: " << setprecision(3) << speedup_full_faster_count_ << "\nGPUTOTAL passed: " << setprecision(3) << speedup_full_equal_count_ << "\nGPUTOTAL failed: " << setprecision(3) << speedup_full_slower_count_ << endl; cout << "\nGPUTOTAL exceeded rate: " << setprecision(3) << (float)speedup_full_faster_count_ / std::max(1, num_subtests_called_) * 100 << "%" << "\nGPUTOTAL passed rate: " << setprecision(3) << (float)speedup_full_equal_count_ / std::max(1, num_subtests_called_) * 100 << "%" << "\nGPUTOTAL failed rate: " << setprecision(3) << (float)speedup_full_slower_count_ / std::max(1, num_subtests_called_) * 100 << "%" << endl; cout << resetiosflags(ios_base::fixed); }
void Output::print(const Vector3D& message, int prec, bool useComma) { if (!_streams[_curStream].print()) return; streamsize origPrec = stream().precision(); for (int i = 0; i < 3; ++i) { stream() << setiosflags(ios::fixed) << setprecision(prec) << checkZero(message[i], prec); stream() << resetiosflags(ios::fixed) << setprecision(origPrec); if (i != 2) { if (useComma) stream() << ","; stream() << " "; } } stream() << flush; }
void TestSystem::printHeading() { cout << endl; cout<< setiosflags(ios_base::left); #if 0 cout<<TAB<<setw(7)<< "Accu." << setw(10) << "CPU (ms)" << setw(10) << "GPU, ms" << setw(8) << "Speedup"<< setw(10)<<"GPUTotal" << setw(10) << "Total" << "Description\n"; cout<<TAB<<setw(7)<<""<<setw(10)<<""<<setw(10)<<""<<setw(8)<<""<<setw(10)<<"(ms)"<<setw(10)<<"Speedup\n"; #endif cout<<TAB<< setw(10) << "CPU (ms)" << setw(10) << "GPU, ms" << setw(8) << "Speedup"<< setw(10)<<"GPUTotal" << setw(10) << "Total" << "Description\n"; cout<<TAB<<setw(10)<<""<<setw(10)<<""<<setw(8)<<""<<setw(10)<<"(ms)"<<setw(10)<<"Speedup\n"; cout << resetiosflags(ios_base::left); }
void Output::print(double message, int prec) { if (!_streams[_curStream].print()) return; int places = prec; if (places == -1) { double temp = message; for (places = 0; places <= 8; ++places) { if ((temp - roundToOne(temp) > -1e-9) && (temp - roundToOne(temp) < 1e-9)) break; temp *= 10; } } streamsize origPrec = stream().precision(); stream() << setiosflags(ios::fixed) << setprecision(places) << checkZero(message, places); stream() << resetiosflags(ios::fixed) << setprecision(origPrec) << flush; }
void print(MPI_Comm comm,int masterRank) { MPI_Comm_size(comm,&N_processes); MPI_Comm_rank(comm,&myrank); profile::masterRank = masterRank; profile::comm = comm; if (myrank != masterRank) { return sendValues(); } cout << left; cout << resetiosflags(ios::floatfield); cout << setprecision(numberWidth-6); cout << setw(nameWidth) << "Name"; cout << setw(numberWidth) << "Calls"; //cout << setw(4*numberWidth) << "Total time (s)"; cout << setw(6*numberWidth) << "Total time (s)"; //cout << setw(4*numberWidth) << "Workunits / s"; cout << endl; cout << setw(nameWidth) << " "; cout << setw(numberWidth) << "Total"; for (int i=0; i<1; ++i) { cout << setw(numberWidth) << "Average"; cout << setw(numberWidth) << "Min"; cout << setw(rankWidth) << "Rank"; cout << setw(numberWidth) << "Max"; cout << setw(rankWidth) << "Rank"; cout << setw(numberWidth) << "Std.dev."; } cout << endl; current = &callTree; for (leafIt = current->daughters.begin(); leafIt != current->daughters.end(); ++leafIt) { print(leafIt->second,leafIt->first,0); } int exitValue = -1; MPI_Bcast(&exitValue,1,MPI_Type<int>(),masterRank,comm); }
void Library::showBooks() const { IdentNum i; if (books.size()==0) cout << "Nao existem livros registados.\n"; else { cout << "#### Livros ####\n"; cout << "---------------------------------------------------------------------------- \n"; cout << "| ID | Titulo | Autor | Disp. |\n"; cout << "---------------------------------------------------------------------------- \n"; cout << setiosflags(ios::left); for (i=1;i<=books.size();i++) { Book bookTemp = getBookByID(i); cout << "| " << setw(MAXIDLENGTH) << bookTemp.getID() << "| " << setw(MAXTITLELENGTH) << bookTemp.getTitle() << "| " << setw(MAXAUTHORLENGTH) << bookTemp.getAuthor() << "| " << setw(MAXQUANTITYLENGTH) << bookTemp.getNumAvailable() << "|\n"; } cout << resetiosflags(ios::left); cout << "---------------------------------------------------------------------------- \n"; } }
void Output::print(const List<double>& message, int prec, bool useComma, bool useAnd) { if (!_streams[_curStream].print()) return; streamsize origPrec = stream().precision(); for (int i = 0; i < message.length(); ++i) { stream() << setiosflags(ios::fixed) << setprecision(prec) << checkZero(message[i], prec); stream() << resetiosflags(ios::fixed) << setprecision(origPrec); if (useComma) { if ((message.length() > 2) && (i != message.length() - 1)) stream() << ","; if ((i == message.length() - 2) && (useAnd)) stream() << " and"; } if (i != message.length() - 1) stream() << " "; } stream() << flush; }
/* only reliable if there are no nested DFSs */ void state_prob_rule_stack::print_probability_so_far() { double prob; while (front > 0) { if (Disk2Stack_needed()) Disk2Stack(); front--; prob = stateArray[front]._prob_reach * stateArray[front]._prob_f; /*if (stateArray[front]._prob_reach > 0 && stateArray[front]._prob_f > 0) { */ if (prob > 0) stateArray[front - 1]._prob_f += prob; /*else { cout << setprecision (6) << setiosflags (ios::scientific) << stateArray[front]._prob_f << setprecision (3) << resetiosflags (ios::scientific) << " * "; } */ } cout << setprecision(10) << setiosflags(ios::scientific) << stateArray[0]._prob_f << setprecision(3) << resetiosflags (ios::scientific) << "\n"; }
std::ostream& Logging::getLog(LogLevel level, const char* file, int line) { #ifdef WIN32 SYSTEMTIME st, lt; GetSystemTime(&st); GetLocalTime(<); #else timeval current_time; gettimeofday(¤t_time, 0); struct tm* tm = localtime(¤t_time.tv_sec); #endif log_stream_ << "[ " << levelToChar(level) << " | " // NOTE(mberlin): Disabled output of __FILE__ and __LINE__ since they are // not used in the current (3/2012) code base. // << file << ":" << line << " | " << setiosflags(ios::dec) #ifdef WIN32 << setw(2) << lt.wMonth << "/" << setw(2) << lt.wDay << " " << setfill('0') << setw(2) << lt.wHour << ":" << setfill('0') << setw(2) << lt.wMinute << ":" << setfill('0') << setw(2) << lt.wSecond << "." << setfill('0') << setw(3) << lt.wMilliseconds << " | " #else << setw(2) << (tm->tm_mon + 1) << "/" << setw(2) << tm->tm_mday << " " << setfill('0') << setw(2) << tm->tm_hour << ":" << setfill('0') << setw(2) << tm->tm_min << ":" << setfill('0') << setw(2) << tm->tm_sec << "." << setfill('0') << setw(3) << (current_time.tv_usec / 1000) << " | " #endif << left << setfill(' ') << setw(14) << boost::this_thread::get_id() << " ] " // Reset modifiers. << setfill(' ') << resetiosflags(ios::hex | ios::left); return log_stream_; }
void Library::showUsers() const { IdentNum i; if (users.size()==0) cout << "Nao existem utilizadores registados.\n"; else { cout << "#### Utilizadores ####\n"; cout << "--------------------------------------------------------------- \n"; cout << "| ID | Nome | Activo |\n"; cout << "--------------------------------------------------------------- \n"; cout << setiosflags(ios::left); for (i=1;i<=users.size();i++) { User userTemp=getUserByID(i); cout << "| " << setw(MAXIDLENGTH) << userTemp.getID() << "| " << setw(MAXNAMELENGTH) << userTemp.getName() << "| "; if (userTemp.isActive()) cout << setw(8) << "Sim" << "|\n"; else cout << setw(8) << "Nao" << "|\n"; } cout << resetiosflags(ios::left); cout << "--------------------------------------------------------------- \n"; } }
void main() { clrscr(); cout.setf(ios::showpoint); cout<<setw(5)<<"\n"; cout<<setw(15)<<"INVERSE OF N"; cout<<setw(15)<<"SUM OF TERMS \n"; double term,sum=0; int i; for(i=0;i<11;i++) { term=1.0/float(i); sum+=term; cout<<setw(5)<<i; cout<<setw(14)<<setprecision(5); cout<<setiosflags(ios::scientific)<<term; cout<<setw(13)<<resetiosflags(ios::scientific); cout<<sum<<endl; } getch(); }