parent
3aeed6f94b
commit
7abc07445d
@ -1,3 +1,3 @@
|
||||
LD_LIBRARY_PATH=/home/hai/sledge-old/runtime/bin
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_SANDBOX_PERF_LOG=/home/hai/sledge-serverless-framework/debuglog.txt
|
||||
SLEDGE_SANDBOX_PERF_LOG=/home/hai/sledge-old/runtime_sandbox_perf_log.log
|
||||
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,46 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
unsigned long int fib(unsigned long int n) {
|
||||
if (n <= 1) return n;
|
||||
return fib(n - 1) + fib(n - 2);
|
||||
}
|
||||
|
||||
int main() {
|
||||
char buffer[1024]; // Buffer to store input data
|
||||
|
||||
// Read data from stdin into buffer
|
||||
ssize_t bytes_read = read(0, buffer, sizeof(buffer) - 1);
|
||||
if (bytes_read < 0) {
|
||||
perror("Error reading input");
|
||||
return 1;
|
||||
}
|
||||
buffer[bytes_read] = '\0'; // Null-terminate the string
|
||||
|
||||
// Variables to store the two numbers
|
||||
unsigned long int num1, num2;
|
||||
|
||||
// Split the input into two parts based on newline and parse them
|
||||
char *line = strtok(buffer, "+");
|
||||
if (line != NULL && sscanf(line, "%lu", &num1) == 1) {
|
||||
line = strtok(NULL, "\n");
|
||||
if (line != NULL && sscanf(line, "%lu", &num2) == 1) {
|
||||
// Calculate Fibonacci numbers and their sum
|
||||
unsigned long int fib1 = fib(num1);
|
||||
unsigned long int fib2 = fib(num2);
|
||||
unsigned long int sum = fib1 + fib2;
|
||||
|
||||
printf("Fibonacci(%lu) + Fibonacci(%lu) = %lu + %lu = %lu\n", num1, num2, fib1, fib2, sum);
|
||||
} else {
|
||||
printf("Invalid input. Please enter two numbers on separate lines.\n");
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
printf("Invalid input. Please enter two numbers on separate lines.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Binary file not shown.
Loading…
Reference in new issue