Hirdetés
- Kompatibilis lett az Android Quick Share és az Apple AirDrop
- Akciófigyelő: Black Friday kedvezmények az EarFun cuccaira
- Akciófigyelő: Huawei Black Friday akciók a tudatos életvitel jegyében
- Részletes fotókon a Honor robotkaros telefonja
- Ezekkel a kiegészítőkkel még sokoldalúbb eszközzé válik az Armor Pad 5
- Honor Magic V5 - méret a kamera mögött
- Bemutatkozott a Poco X7 és X7 Pro
- Samsung Galaxy S25 Ultra - titán keret, acélos teljesítmény
- Az AI miatt drágulnak a mobilok is
- Részletes fotókon a Honor robotkaros telefonja
- Milyen hagyományos (nem okos-) telefont vegyek?
- iPhone topik
- Xiaomi 15T - reakció nélkül nincs egyensúly
- Megtartotta Európában a 7500 mAh-t az Oppo
- Samsung Galaxy Watch4 és Watch4 Classic - próbawearzió
- Ndruu: Segíts kereshetővé tenni a PH-s arcképeket!
- GoodSpeed: 3I/Atlas: Üstökös vagy idegen civilizáció űrhajója?
- Sub-ZeRo: Euro Truck Simulator 2 & American Truck Simulator 1 (esetleg 2 majd, ha lesz) :)
- gban: Ingyen kellene, de tegnapra
- kraftxld: Diáklaptop - Dell Latitude 3140 - Királyunk ajándéka
Új hozzászólás Aktív témák
-
icespeak
csendes tag
Hellótok C++-ban a header fájlnál van problémám a függvényekkel
#include "read.h"
#include "ellenoriz.h"
#include <iostream>
#include <vector>
#include <sstream>
#include <fstream>
using namespace std;
int main(int argc, char *argv[])
{
vector<vector<int> > t;
char ch;
do{
// Adatok beolvasása
vector<vector<int> > t;
bool file_ok = true;
// Adatbevitel módja
int v;
if(argc>1) v = 1;
else{
cout << "Az adatbeolvasás módja:"<< endl
<< " SZÖVEGES FÁJL(1)"<< endl
<< " BILLENTYŰZET (2)"<< endl;
v = Read12("Válasszon: ","Csak 1 vagy 2 közül választhat!");
}
// Beolvasás
string fname;
switch(v)
{
case 1 :
if(argc<=1){
cout << "Adja meg a szöveges fájl nevét: ";
cin >> fname;
}
else fname = argv[1];
file_ok = ReadFromFile(fname, t);
break;
case 2 :
cout << "Adja meg az értékeket!";
ReadFromKeyboard(t);
break;
}
// Kiíratás
if(file_ok)
{
if(minden(t)) cout << "Minden sorban van legalabb egy primszam"<< endl;
else cout << "Nincs minden sorban primszam"<< endl;
cout << endl << "Futtassam újra? (I/N) "; cin >> ch;
}
}while(ch!='n' && ch!='N');
return 0;
}
read.cpp tartalma
#include "read.h"
#include <iostream>
#include <vector>
#include <fstream>
using namespace std;
int Read12(const string &msg, const string &errormsg)
{
int n;
bool hiba = true;
do{
cout << msg;
string str;
cin >> str;
n = atoi(str.c_str());
hiba = (n==0 && str!="0") || n<1 || n>2;
if(hiba) cout << errormsg << endl;
}while(hiba);
return n;
}
void ReadFromKeyboard(vector<vector<int> > &t)
{
int n=ReadNat("kerek egy pozitiv egesz szamot( hany soros a matrix):\t","nem pozitiv egesz szamot adtal meg!");
int m=ReadNat("kerek egy pozitiv egesz szamot( hany oszlopa van a matrixnak):\t","nem pozitiv egesz szamot adtal meg!");
t.resize(n);
for (int i=0;i<n;i++)
{
t[i].resize(m);
for (int j=0;j<m;j++)
{
cout <<"t["<<i+1<<"]["<<j+1<<"]: ";
t[i][j]=ReadInt("","nem szamot adtal meg!");
}
}
}
bool ReadFromFile(const string &fname)
{
int n,m,ertek;
int t[n][m];
ifstream x(fname.c_str());
if(x.fail()){
cout << "Hibás fájlnév!"<< endl;
return false;
}
while(!x.eof()){
for (int i=0;i<n;i++)
{
for (int j=0;j<m;j++)
{
x >> ertek;
t[i][j]=ertek;
}
}
}
return true;
}
bool good(int k) {
if (k>0)
{
return true;
}
else
{
return false;
}
}
int ReadInt(string msg, string errormsg, bool cond(int) )
{
int n;
bool hiba;
do{
cout << msg;
string str;
cin >> str;
n = atoi(str.c_str());
hiba = n==0 && str!="0" || !cond(n);
if(hiba) cout<< errormsg<< endl;
}while(hiba);
return n;
}
int ReadNat(string msg, string errormsg, bool cond(int) )
{
int n;
bool hiba;
do{
cout << msg;
string str;
cin >> str;
n = atoi(str.c_str());
hiba = n==0 && str!="0" || n<0 || !cond(n);
if(hiba) cout<< errormsg<< endl;
}while(hiba);
return n;
}
read.h tartalma
#ifndef _READ_
#define _READ_
#include <string>
bool good(int k);
int Read12(const string &msg, const string &errormsg);
void ReadFromKeyboard(vector<vector<int> > &t);
bool ReadFromFile(const string &fname);
int ReadInt(std::string msg, std::string errormsg, bool cond(int) = good);
int ReadNat(std::string msg, std::string errormsg, bool cond(int) = good);
#endif
Új hozzászólás Aktív témák
● ha kódot szúrsz be, használd a PROGRAMKÓD formázási funkciót!
- Bomba ár! Dell Latitude 3410 - i3-10110U I 8GB I 256SSD I HDMI I 13,3" FHD Touch I Cam I W11 I Gari
- Bomba ár! Dell Latitude E5550 - i5-5GEN I 8GB I 128SSD I 15,6" FHD Touch I HDMI I W10 I Cam I Gari!
- Bomba ár! Dell Latitude E5540 - i5-4GEN I 4GB I 240SSD I Nvidia I 15,6" FHD I Cam I W10 I Garancia!
- Olcsón Google Nest Mini 2nd Gen
- Bomba ár! Dell Latitude E5530 - i5-3GEN I 4GB I 320GB I HDMI I 15,6" HD I W10 I Gari!
- LG 48C3 - 48" OLED evo - 4K 120Hz 1ms - NVIDIA G-Sync - FreeSync Premium - HDMI 2.1 - A9 Gen6 CPU
- Shure Podcast mikrofon
- GYÖNYÖRŰ iPhone 13 Pro 128GB Graphite -1 ÉV GARANCIA - Kártyafüggetlen, MS3962, 100% Akkumulátor
- Microsoft Surface Laptop 5 13,5" Fekete i7-1265U 16GB 512GB magyarbill 1 év garancia
- Eladó Xiaomi Redmi A5 3/64GB / 12 hónap jótállással!
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
Cég: Laptopműhely Bt.
Város: Budapest


