C Programming Lab
Implementation using C in programming lab class when being Teacher Assistant.
The problems are here
Problems and Description
- Week2
- week2-1
- Description: A man walks X km in Y hours in the same direction. What is the man's velocity in km/h for the journey?
- Input: Input contain two number in a line and separate by a single space, first number stand for distance in km, second number stand for time in hour.
- Output: A number stand for velocity in km/h, please rounded to six decimal places.
- week2-2
- Description: Read a 4 digit number, reverse it and display it.
- Input: A 4 digit number, first digit is not 0.
- Output: A 4 digit number after reverse.
- week2-3
- Description: Read in a number, round it down to an integer and display on screen.
- Input: A number.
- Output: Display the integer after round down.
- week2-4
- Description: Please write a program allow user input two integer and print out the result of addition subtraction multiplication division and modulo of two integer.
- Input: Two integer separate by a single space.
- Output: See sample output.
- week2-5
- Description: Please write a program allow user input two floating point number and print out the result of addition, subtraction, multiplicationanddivision of two number.
- Input: Two floating point number separate by a single space
- Output: See sample output
- week2-6
- Description: Gave you a number n, please find the maximum even number less than or equal to n.
- Input: An positive integer n.
- Output: An largest even number less than or equal to n.
- week2-1
- Week3
- week3-1
- Description: Please input an integer, determine if the integer is odd or even.
- Input: Just an integer.
- Output: output "odd" if the integer is odd, "even" if the integer is even.
- week3-2
- Description: Read in two integer m and n, determine if m is multiple of n.
- Input: Input will be two integer m and n separate by a single space.
- Output: Please reference the sample out
- week3-3
- Description: We use two points to present a segment in one dimensional coordinates. Give you two segment, your job is to determine two segment are overlay or not.
- Input: Input consist 4 integer, first two present segment 1, and follow two present segment 2.
- Output: Print "overlay" if two segment overlay, "no overlay" if not.
- week3-4
- Description: Three segment length a, b, c, c has maximum length, if a + b > c than these three segment can construct a triangle. If a * a + b * b = c * c it will be a "right triangle", if a * a + b * b > c * c it will be a "acute triangle", if a * a + b * b < c * c it will be a "obtuse triangle". Write a program to determine what kind of triangle it will be.
- Input: Input consist three integer a, b, c, c will be the maximum value.
- Output: 如果三個線段可以構成一個三角形,就輸出他是哪種三角形,如果是銳角三角形就輸出 "acute triangle" ,如果是鈍角三角形就輸出 "obtuse triangle" ,如果是直角三角形就輸出 "right triangle"。如果三個線段無法構成一個三角形則輸出 "can not construct"
- week3-1
- Week4
- week4-1
- Please write a program that can keep read in integer until 0, sum up all integer and print out the result.
- Input consist several integer until 0.
- sum of all integer.
- week4-2
- Please write a program read in an integer and print out all its factor.
- Input consist an positive integer.
- Print out all factors incremental ordering.
- week4-3
- Please write a program to determine if a number is prime or not.
- Input consist several test case. Every test case is just a integer. Input ended with 0.
- For every test case output "prime" if the input is a prime number, output "not a prime" if not.
- week4-4
- Please write a program, input a positive integer to represent the number of regular triangle layers, and print this triangle.
- A[1, 30] positive integer.
- Print this regular triangle.
- week4-5
- Please write a program for prime factorization.
- Input consist several test case. Every test case is just a integer. Input ended with 0.
- Please reference the sample output.
- week4-6
- Morse code is a character encoding scheme used in telecommunication that encodes text characters as standardized sequences of two different signal durations called dots and dashes or dits and dahs. Morse code is named for Samuel F. B. Morse, an inventor of the telegraph. Write a program allow user input a number and print out corresponding Morse code.
- Input is an integer number.
- Print out the corresponding Morse code.
- week4-7
- Given the square root of a positive integer N is between 0 and N, let the square root of N be x, a=0 is the lower bound, and b=N is the upper bound. Then there is the inequality a<=x<=b, square the inequality to get aa<=xx=N<=b*b, and let c = (a+b)/2 according to the root approximation through bisection, when square of c is greater than or equal to N, we update the upper bound and get a new inequality a<=x<=c, otherwise, we update the lower bound and get a new inequality c<=x<=b. The difference between the upper and lower bounds is called the error. Please design a program in which the user enters a positive integer and calculates the square root of the positive integer. Please be accurate to four decimal places.
- An integer n.
- Output the root of naccurate to four decimal places.
- week4-1
License
None License