Reverse Alphabet
Description
Executing Reverse Alphabet
The Code
Source
fn run_task(input: String) -> String {
input.chars().rev().collect()
}
fn main() {
let input: String =
std::fs::read_to_string("input.txt").expect("Could not read from input.txt");
let output = run_task(input);
std::fs::write("output.txt", output).expect("Could not write to output.txt");
}#include <stdio.h>
#include <stdlib.h>
int fibonacci(int n) {
int a = 0, b = 1, c;
for (int i = 2; i <= n; i++) {
c = a + b;
a = b;
b = c;
}
return b;
}
int main() {
FILE *inputFile = fopen("input.txt", "r");
if (inputFile == NULL) {
perror("Error opening input.txt");
return 1;
}
int input;
if (fscanf(inputFile, "%d", &input) != 1) {
perror("Error reading input.txt");
fclose(inputFile);
return 1;
}
fclose(inputFile);
int result = fibonacci(input);
FILE *outputFile = fopen("output.txt", "w");
if (outputFile == NULL) {
perror("Error opening output.txt");
return 1;
}
fprintf(outputFile, "%d", result);
fclose(outputFile);
return 0;
}In/Out Parameters
Trying Out
Step 1: Create The Reverse Alphabet Source Code
Step 2: Build The Source Code
Output
Step 3: Try The Code
Output
Step 4: Deploy the task
Output
Last updated
Was this helpful?