mirror of https://github.com/01-edu/public.git
Frenchris
6 years ago
committed by
GitHub
5 changed files with 100 additions and 0 deletions
@ -0,0 +1,30 @@
|
||||
## fprime |
||||
|
||||
### Instructions |
||||
|
||||
Write a program that takes a positive `int` and displays its prime factors on the standard output, followed by a newline. |
||||
|
||||
- Factors must be displayed in ascending order and separated by `*`, so that the expression in the output gives the right result. |
||||
|
||||
- If the number of parameters is not 1, the program displays a newline. |
||||
|
||||
- The input, when there is one, will always be valid. |
||||
|
||||
Example of output : |
||||
|
||||
```console |
||||
student@ubuntu:~/piscine/test$ go build |
||||
student@ubuntu:~/piscine/test$ ./test 225225 |
||||
3*3*5*5*7*11*13 |
||||
student@ubuntu:~/piscine/test$ ./test 8333325 |
||||
3*3*5*5*7*11*13*37 |
||||
student@ubuntu:~/piscine/test$ ./test 9539 |
||||
9539 |
||||
student@ubuntu:~/piscine/test$ ./test 804577 |
||||
804577 |
||||
student@ubuntu:~/piscine/test$ ./test 42 |
||||
2*3*7 |
||||
student@ubuntu:~/piscine/test$ ./test |
||||
|
||||
student@ubuntu:~/piscine/test$ |
||||
``` |
@ -0,0 +1,26 @@
|
||||
## revWstr |
||||
|
||||
### Instructions |
||||
|
||||
Write a program that takes a string as a parameter, and prints its words in reverse. |
||||
|
||||
- A word is a sequence of **alphanumerical** characters. |
||||
|
||||
- If the number of parameters is different from 1, the program will display `\n`. |
||||
|
||||
- In the parameters that are going to be tested, there will not be any additional spaces. (meaning that there will not be additionnal spaces at the beginning or at the end of the string, and words will always be separated by exactly one space). |
||||
|
||||
Examples of outputs : |
||||
|
||||
```console |
||||
student@ubuntu:~/piscine/test$ go build |
||||
student@ubuntu:~/piscine/test$ ./test "the time of contempt precedes that of indifference" |
||||
indifference of that precedes contempt of time the |
||||
student@ubuntu:~/piscine/test$ ./test "abcdefghijklm" |
||||
abcdefghijklm |
||||
student@ubuntu:~/piscine/test$ ./test "he stared at the mountain" |
||||
mountain the at stared he |
||||
student@ubuntu:~/piscine/test$ ./test |
||||
|
||||
student@ubuntu:~/piscine/test$ |
||||
``` |
@ -0,0 +1,37 @@
|
||||
## sortList |
||||
|
||||
### Instructions |
||||
|
||||
Write a function that must: |
||||
|
||||
- Sort the list given as a parameter, using the function cmp to select the order to apply, |
||||
|
||||
- Return a pointer to the first element of the sorted list. |
||||
|
||||
Duplications must remain. |
||||
|
||||
Inputs will always be consistent. |
||||
|
||||
The `type NodeList` must be used. |
||||
|
||||
Functions passed as `cmp` will always return `true` if `a` and `b` are in the right order, otherwise it will return `false`. |
||||
|
||||
### Expected function |
||||
|
||||
```go |
||||
func SortList (l *NodeList, cmp func(a,b int) bool) *NodeList{ |
||||
|
||||
} |
||||
``` |
||||
|
||||
- For example, the following function used as `cmp` will sort the list in ascending order : |
||||
|
||||
```go |
||||
func ascending(a, b int) bool{ |
||||
if a <= b { |
||||
return true |
||||
} else { |
||||
return false |
||||
} |
||||
} |
||||
``` |
Loading…
Reference in new issue