Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Subject: Automata Theory and Compiler Design
- * Author: Tareq Hasan <http://tareq.weDevs.com>
- *
- * Experiment: 3
- * Write a Program that read a string and abbreviates
- *
- * Sample Input: CSE-307
- * Sample Output: Computer Science & Engineering, 3rd Year, Artifitial Inteligence
- */
- #include <iostream>
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- using namespace std;
- #define SUB_MAX 5
- int main() {
- char input[20];
- cout << "Enter subject code: ";
- cin >> input;
- string subjects[][SUB_MAX] = {{
- "Introduction to Programming with C and C++ ",
- "Digital Systems",
- "Computer Fundamentals",
- "Electronics and Electrical Circuits",
- "English"
- }, {
- "Object Oriented Programming",
- "Data StructureJ",
- "Algorithms",
- "Computer Architecture and Organization",
- "Numerical Methods"
- }, {
- "DBMS",
- "Network",
- "Automata theory and Compiler Design",
- "Operating System",
- "Assembly Language"
- }, {
- "Digital Image Processing",
- "Computer Simulation and Modelling",
- "E-Commerce and Web Engineering",
- "Software Engineering",
- "System Analysis and Design"
- }};
- string years[] = { "1st Year", "2nd Year", "3rd Year", "4th Year" };
- char *token = strtok( input, "-" );
- while( token != NULL ) {
- if( strcmp( token, "CSE") ) {
- cout << "Computer Science & Engineering, ";
- }
- if( isdigit( token[0] ) ) {
- cout << years[token[0]-49] << ", ";
- }
- if( isdigit( token[2] ) ) {
- cout << subjects[token[0]-49][token[2]-49] << endl;
- }
- token = strtok( NULL, "-" );
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement