Pereiti prie turinio

Rekomenduojami pranešimai

http://1drv.ms/1VGTsl1

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
//-----------------------------
const char CDfv[] = "Duomenys2.txt";
const char CRfv[] = "Rezultatai1.txt";
//-----------------------------
void Nuskaitymas(int &n, string R[]);
char Keisti(string s);
void Isvedimas(string R[], int n);
//-----------------------------
int main() {
int n;		//kiek masyve nariø
string R[100];
/*Kreipiniai į funckijas*/
Nuskaitymas(n, R);      //Nuskaitymas: nuskaito šifrą ir sudeda į masyvą R
int k=0;

for(int i=0; i <n-1;i++){
    string t = R[i];
    R[i]=R[i+1];
    R[i+1]=t;
    i++;
}
//R[n]+= " "; R[n]=Keisti(R[n]);
Isvedimas(R,n);         //Išvedimas: išveda atkoduotas raides
return 0;
}
void Nuskaitymas(int &n, string R[]) {
n = 0;
ifstream fd(CDfv);
while (!fd.eof()) {
	getline(fd, R[n], ' '); //Nuskaito koduotą raidę iki tarpo
       n++;
}
fd.close();
}
char Keisti(string s) {
char x;
if (s == "*- ") x = 'A';
else if (s == "*-*- ") x = 'Ą';
else if (s == "-*** ") x = 'B';
else if (s == "-*-* ") x = 'Č';
else if (s == "---* ") x = 'Ė';
else if (s == "-** ") x = 'D';
else if (s == "* ") x = 'E';
else if (s == "**-** ") x = 'Ę';
else if (s == "**-* ") x = 'F';
else if (s == "--* ") x = 'G';
else if (s == "**** ") x = 'H';
else if (s == "** ") x = 'I';
else if (s == "-*-- ") x = 'Y';
else if (s == "*--- ") x = 'J';
else if (s == "-*- ") x = 'K';
else if (s == "*-** ") x = 'L';
else if (s == "-- ") x = 'M';
else if (s == "-* ") x = 'N';
else if (s == "--- ") x = 'O';
else if (s == "*--* ") x = 'P';
else if (s == "--*- ") x = 'Q';
else if (s == "*-* ") x = 'R';
else if (s == "*** ") x = 'S';
else if (s == "---- ") x = 'Ð';
else if (s == "- ") x = 'T';
else if (s == "**- ") x = 'U';
else if (s == "**-- ") x = 'Ū';
else if (s == "**-- ") x = 'Ų';
else if (s == "***- ") x = 'V';
else if (s == "*-- ") x = 'W';
else if (s == "-**- ") x = 'X';
else if (s == "--** ") x = 'Z';
else if (s == "--** ") x = 'Ž';
else if (s == "----- ") x = '0';
else if (s == "*---- ") x = '1';
else if (s == "**--- ") x = '2';
else if (s == "***-- ") x = '3';
else if (s == "****- ") x = '4';
else if (s == "***** ") x = '5';
else if (s == "-**** ") x = '6';
else if (s == "--*** ") x = '7';
else if (s == "---** ") x = '8';
else if (s == "----* ") x = '9';
else if (s == "****** ") x = '.';
else if (s == "*-*-* ") x = ',';
else if (s == "**-** ") x = '?';
else if (s == "--**-- ") x = '!';
else if (s == "-****- ") x = '-';
else if (s == "*-**-* ") x = '"';
else if (s == "-*-*-* ") x = ';';
else if (s == "---*** ") x = ';';
else if (s == " ") x = ' ';
return x;
}
void Isvedimas(string R[], int n){
   ofstream fr(CRfv);
   for(int i=0; i <n; i++)
       fr << R[i] << " ";
   fr.close();
}

Nesigauna apkeist narius, maždaug padariau, kad nuskaityt su getline iki tarpo, o vėliau darau +=" " kad pridėt tarpą, nes tarp simbolių tarpas yra. Tik va niekaip apkeitimas porinis tarpusavyje nesigauna. Gal kažką pasiūlysit? :) Po žodžio, t.y 4 simbolių dedu dar vieną tarpą, nes vienas nuo simbolio o kitas šiaip tarp žodžių.

Redagavo Reserved
Nuoroda į pranešimą
Dalintis kituose puslapiuose

Prisijunkite prie diskusijos

Jūs galite rašyti dabar, o registruotis vėliau. Jeigu turite paskyrą, prisijunkite dabar, kad rašytumėte iš savo paskyros.

Svečias
Parašykite atsakymą...

×   Įdėta kaip raiškusis tekstas.   Atkurti formatavimą

  Only 75 emoji are allowed.

×   Nuorodos turinys įdėtas automatiškai.   Rodyti kaip įprastą nuorodą

×   Jūsų anksčiau įrašytas turinys buvo atkurtas.   Išvalyti redaktorių

×   You cannot paste images directly. Upload or insert images from URL.

Įkraunama...
  • Dabar naršo   0 narių

    Nei vienas registruotas narys šiuo metu nežiūri šio puslapio.

×
×
  • Pasirinkite naujai kuriamo turinio tipą...