Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Rozwiazanie
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here Console.WriteLine(Reverse("Kajak")); } /* * Odwroc kolejnosc znakow */ public static string Reverse(string text) { var reversed = string.Empty; for(var i=0;i<text.Length;i++) { reversed = reversed + text[text.Length - 1 - i]; } return reversed; } /* * Czy text zawiera slowo */ public static bool Contains(string text,string word) { if(text.Length < word.Length) return false; for(var i=0;i<text.Length-word.Length;i++) { bool contains = true; for(var j=0;j<word.Length;j++) { if(text[i+j]!=word[j]) { contains =false; break; } } if(contains) return true; } return false; } /* * Male litery do duzych */ public static string ToUpper(string text) { string upper = string.Empty; for(var i=0;i<text.Length;i++) { upper += Char.ToUpper((text[i])); } return upper; } /* * Duze litery do malych */ public static string ToLower(string text) { string lower = string.Empty; for(var i=0;i<text.Length;i++) { lower += Char.ToLower((text[i])); } return lower; } /* * Male do duzych duze do malych */ public static string UpperToLowerLowerToUpper(string text) { var upperAndLower = string.Empty; for(var i=0;i<text.Length;i++) { upperAndLower += Char.IsLower(text[i]) ? Char.ToUpper(text[i]) : Char.ToLower(text[i]); } return upperAndLower; } /* * Ile razy slowo wystepuje w zdaniu */ public static int WordOccurence(string text,string word) { var count = 0; for(var i=0;i<text.Length;i++) { bool contains = true; for(var j=0;j<word.Length;j++) { if(text[i+j] != word[j]) { contains =false; break; } } if(contains) count++; } return count; } /* * Zlicza liczbe slow w zdaniu */ public static int WordCount(string text) { var separators = new char[]{' ','.',','}; var count=0; for(var i=0;i<text.Length;i++) { //jesli wystepuje jakis oddzielajacy znak i nie ma go na koncu zdania lub nie ma podwojnej spacji lub przecinka count ++ if(separators.Contains(text[i])&& i < text.Length && !separators.Contains(text[i+1]) ) count ++; } return count; } /* * Sprawdza czy jest palindromem */ public static bool IsPalindrome(string word) { var isPalindrome = true; for(var i=0;i<word.Length;i++) { if(word[i]!=word[word.Length - 1 -i]) isPalindrome = false; } return isPalindrome; } } }
run
|
edit
|
history
|
help
0
12345
Fórum ➡ Calculate the Sum of Values in List of KeyValuePair<> objects ♦
test
1
Testing 001
z x xc x
Finding a Substring in a Main String
train 11111111
c# değişik bir çizim
blanaced parenthes