Miniprojecto da disciplina de Introdução a Programação realizada na linguagem C no meu primeiro ano de curso (2017)
O miniprojecto tem como objetivo aprofundar os seus conhecimentos na linguagem de programação C, colocando em prática os conhecimentos já adquiridos, desde estruturas condicionadas, de repetição e estruturas de múltiplas escolhas, funções e procedimentos, etc. Para tal irá desenvolver um programa em C, baseando em funções, com a seguinte estrutura:
Ao executar o programa deverá ser apresentado o seguinte menu de opções:
O utilizador escolhe entre uma destas opções:
1- O programa deve mostrar a diferença entre a soma dos quadrados dos primeiros N números naturais e o quadrado da soma dos mesmos. Por exemplo: A soma dos quadrados dos dez primeiros números naturais ´e, 12 + 22 + ... + 102 = 385. O quadrado da soma dos dez primeiros números naturais ´e, (1 + 2 + ... + 10) 2 = 552 = 3025. Daí a diferença entre a soma dos quadrados dos dez primeiros números naturais e o quadrado da soma ´e 3025 - 385 = 2640.
2- Considere uma fração no formato N/M sendo N inteiro (0 <= N <= 10000) e M inteiro (1 <= M <= 10000). O programa deve ser capaz de simplificar uma fração neste formato tal que o novo numerador e o novo denominador sejam mínimos. O programa receberá um conjunto de testes composto por um número indefinido de linhas. Cada linha conterá os valores de N e M separados por um espaço. O final da entrada será indicado por N=M=0. A saída do programa deverá ser a fração simplificada na mesma ordem da entrada uma em cada linha separando-se o numerador e o denominador por espaço.
3- Faca um programa capaz de operar dois números de 0-255 informados em binário. A resposta deve ser dada também em binário. Deve-se aceitar os seguintes operadores: +,-,*,/.
4- Faça um programa que solicite números inteiros I (−4000 <= I <= 4000) enquanto I for diferente de zero. Quando I for zero o programa deve imprimir todos os sucessores inteiros imediatos de cada I informado. Observe que neste problema não há um limite para a quantidade de números I informados.
5- Escrever um programa que determine o histograma, media e desvio padrão de um vetor de reais. O histograma representa, num vetor apropriado, o numero de ocorrências dos n elementos do vetor em cada um de k intervalos de largura (max(x) – min(x))/k. O desvio padrão, s, é uma medida de dispersão dos elementos de x em torno da media, m , e é definido como:
6- Faça um programa capaz de aceitar uma string S e um grupo de N palavras P. Para cada palavra digitada deve-se verificar a possibilidade de formá-la com as letras da string informada. Considere que: Todas as palavras serão digitadas em letras minúsculas e cada elemento de P terão tamanho máximo de 100 caracteres. Para cada elemento de P caso seja possível formá-lo com os caracteres de S o programa deverá responder OK, caso contrário -1.
Miniproject of the Introduction to Programming course done in C language in my first year of course (2017)
The miniproject aims to deepen your knowledge of the C programming language, putting into practice the programming language, putting into practice the knowledge already acquired, from conditional conditional, repetition and multiple choice structures, functions and procedures etc. To do this you will develop a C program, based on functions, with the following structure:
When you run the program you should be presented with the following menu of options:
The user chooses between one of these options:
1- The program should show the difference between the sum of the squares of the first N natural numbers and the square of their sum. For example: The sum of the squares of the first ten natural numbers 'e, 12 + 22 + ... + 102 = 385. The square of the sum of the first ten natural numbers 'e, (1 + 2 + ... + 10) 2 = 552 = 3025. Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum 'e 3025 - 385 = 2640.
2- Consider a fraction in the form N/M where N is integer (0 <= N <= 10000) and M integer (1 <= M <= 10000). The program should be able to simplify a fraction in this format such that the new numerator and denominator are minimal. The program will be given a test set consisting of an indefinite number of lines. Each line will contain the values of N and M separated by a space. The end of the input will be indicated by N=M=0. The output of the program should be the simplified fraction in the same order as the input one in each line separating the numerator and denominator by a space.
3- Make a program that can operate two numbers from 0-255 given in binary. The answer must also be given in binary. The following operators must be accepted: +,-,*,/.
4- Make a program that asks for integers I (-4000 <= I <= 4000) while I is non-zero. When I is zero the program should print all the immediate integer successors of each I entered. Notice that in this problem there is no limit to the number of I numbers entered.
5- Write a program that determines the histogram, mean and standard deviation of a vector of reals. The histogram represents, in an appropriate vector, the number of occurrences of n elements of the vector in each of k width intervals (max(x) - min(x))/k. The standard deviation, s, is a measure of dispersion of the elements of x around the mean, m , and is defined as:
6- Make a program capable of accepting a string S and a group of N words P. For each word entered, it must be verified the possibility of forming it with the letters of the string entered. Consider that: The words will be typed in lowercase letters and each element of P will have a maximum size of 100 characters. For each element of P, if it is possible to form it with the characters from S the program should answer OK, otherwise -1.