Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // isPalindrome.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- using namespace std;
- string isPalindrome(string inntak);
- int main()
- {
- system("chcp 1252>NUL");
- string test = "";
- string lausn = "";
- cout << "sláðu inn orð sem þú vilt prófa: ";
- cin >> test;
- lausn = isPalindrome(test);
- cout << lausn;
- return 0;
- }
- string isPalindrome(string inntak)
- {
- string nidurstada = "";
- int lengd = inntak.length;
- string ofugt = "";
- for (int i = lengd; i >= 0; i--);
- ofugt += inntak[i];
- if (inntak == ofugt)
- {
- nidurstada = "þettað orð er palindrome";
- }
- else
- {
- nidurstada = "þettað orð er ekki palindrome";
- }
- return nidurstada;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement