Programación
Busca apuntes, exámenes y más
Photo of the basic version of the third mid term: reading a text file, asking the user for a number, selecting the records that meet each criterion in order of priority and writing the chosen ones into a new file. With the full example of execution.
Photo of the advanced version of the third mid term: the program reads a second file with the identifiers of the available items and their number of units, assigns them in the order they appear, and writes the result into the output file. With the example
Photo of the full second mid term exam paper with the three exercises and their marks: writing a function that inserts words into a sentence at given positions, the variant that inserts them after the given words, and the version with a fourth parameter.
Second version of the function that inserts words into a sentence at given positions, splitting the sentence into parts according to the positions vector and concatenating everything, commented step by step.
One page listing the most commonly used MATLAB functions for working with strings, each one with the meaning of its arguments and what it returns: comparison, search, replacement, splitting, case conversion and trimming.
Complete review booklet for the final exam of the 2020-21 course, with every exercise fully solved: strings, cell arrays, vectors of structures, files, recursion and the search and sort algorithms, with a content table at the front.
Exercises part of the January 2012 exam: the findWord function that reads a file and looks for a word, and the other problems with their marks. 5 pages in English.
Exercises part of the January 2011 exam: the copydata function that builds a new vector from an existing one, and the rest of the problems with their marks. 3 pages in English.
Function that receives a vector of values and prints on screen how many times each different value appears, with the example of execution showing the expected output.
Function that receives a string and prints the sentence with each of its words spelled backwards, keeping the words in the same order, with the example A cat is an animal.
Function that receives a vector of integers and returns it without repeated numbers, with the sorting part of the exercise included.
Function that searches for occurrences of one string inside another and replaces them by a third string, with the worked example of turning the into test in a sentence.
Short script that sets a sample sentence, the words to insert and the vector of positions, and calls addTexts2 so the result can be checked.
Recursive function that proves Ulam conjecture: halve the number when it is even, multiply by three and add one when it is odd, until reaching 1, with the program that asks the user for the starting number.
Function that runs through a vector of structures and returns the indexes of the records whose numeric field is above seventy, building the result vector index by index.
Function that runs through a vector of structures and returns the indexes of the records whose field matches the value looked for, using strcmpi so case does not matter.
Recursive function that transforms a number from base ten to any other base, with the main program that asks the user for the number and the new base and prints the result.
Full solution of the third midterm: opening the file with fopen and checking the identifier, reading each record into a vector of structures, running the searches and writing the output file. 2 pages commented for readability.
Script that guesses the number the user is thinking of by halving the interval on each try, counting how many questions it needed. A clean example of binary search.
The myReplace exercise with its full statement, the example of execution and the solution, useful to see how the result should look before writing the code.