Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * main.cpp
- *
- * Created on: Feb 23, 2017
- * Author: student
- */
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main() {
- std::ofstream outfile ("test.cpp");
- std::ifstream infile("input.txt");
- if(infile.is_open())
- {
- string myArray[100];
- for(int i = 0; i < 100; ++i)
- {
- infile >> myArray[i];
- }
- outfile << "#include <iostream>\n#include <fstream>\nusing namespace std;\n int main() {\n" ;
- for(int j = 0; j < 100; ++j)
- {
- if (myArray[j]== "Var ")
- {
- outfile << "\nint ";
- }
- else
- if(myArray[j]==",")
- {
- outfile<<",";
- }
- else
- if (myArray[j]== "a")
- {
- outfile << "<Identificator>::=";
- }
- else if(myArray[j]== "b")
- {
- outfile << "<Identificator>::=";
- }
- else if(myArray[j]== "c")
- {
- outfile << "<Identificator>::=\n";
- }
- else if(myArray[j]== "d")
- {
- outfile << "<Identificator>::=\n";
- }
- else if((myArray[j]=="+")||(myArray[j]=="-"))
- {
- outfile<<"<Operatie>::=""+""|""-"" ";
- }
- else if(myArray[j]=="-")
- {
- outfile<<"<Operatie>";
- }
- else if (myArray[j]== "Input")
- {
- outfile << "cin >> ";
- }
- else if (myArray[j]== "Output")
- {
- outfile << "cout << ";
- }
- else
- {
- outfile << myArray[j] ;
- }
- }
- }
- outfile << "return 0; }" << std::endl;
- cout << "Done !" << endl;
- infile.close();
- outfile.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement