Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // strlen1, strcpy1
- #include <iostream>
- using namespace std;
- #define UINT unsigned int
- UINT strlen1(const char str[]) {
- int len = 0;
- while (str[len] != '\0') {
- len++;
- }
- return len;
- }
- void strcpy1(char dest[], char src[]) {
- int i = 0;
- while (src[i] != '\0') {
- dest[i] = src[i];
- i++;
- }
- dest[i] = '\0';
- }
- int main(int argc, char **argv) {
- cout << "Input: "<< argv[1] << endl;
- cout << "Length: "<< strlen1(argv[1]) << endl;
- char inputCopy[25];
- strcpy1(inputCopy, argv[1]);
- cout << "Copy: "<< inputCopy << endl;
- return 0;
- }
- // факторіал
- #include <iostream>
- #include <stdio.h>
- #include <stdlib.h>
- using namespace std;
- long long factorial(int n) {
- if (n == 0) {
- return 1;
- } else {
- return n * factorial(n - 1);
- }
- }
- int main(int argc, char **argv) {
- int n = atoi(argv[1]);
- cout << "Factorial of "<< n << ": " << factorial(n) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment