Share via

c# programı yazma

Anonymous
2021-02-03T15:29:36.443+00:00

"program bir 'c.txt' dosyası oluşturacak, kullanıcıya içine kaç cümle yazacağını soracak, kullanıcının belirttiği kadar cümleyi dosya içine kaydedecek, sonra da kullanıcının belirlediği bir kelimeyi dosya içinde kaç adet olduğunu ekrana yazacak."

Bu programı yazmamda bana olabildiğince acil yardımcı olur musunuz lütfen?
Bir süredir uğraşıyorum sürekli bir şekilde yanlış oluyor.
program visual studio.

Developer technologies | VB
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Karen Payne MVP 35,606 Reputation points Volunteer Moderator
    2021-02-03T16:06:06.24+00:00

    Hello,

    This is a English speak forum so please next time use a language converter to English.

    Here is a start that creates sentences taken from here and placed into a class

    Usage

    var paragraphs = Generator.LoremIpsum(2, 10, 10, 10, 10).Replace("</p>", "</p>\n");
    File.WriteAllText("c.txt", paragraphs);
    

    Class

    public class Generator
    {
        public static string LoremIpsum(int minWords, int maxWords, int minSentences, int maxSentences, int numParagraphs)
        {
    
            var words = new[]{"lorem", "ipsum", "dolor", "sit", "amet", "consectetuer",
                "adipiscing", "elit", "sed", "diam", "nonummy", "nibh", "euismod",
                "tincidunt", "ut", "laoreet", "dolore", "magna", "aliquam", "erat"};
    
            var rand = new Random();
            int numSentences = rand.Next(maxSentences - minSentences) + minSentences + 1;
            int numWords = rand.Next(maxWords - minWords) + minWords + 1;
    
            var sb = new StringBuilder();
    
            for (int positionIndex = 0; positionIndex < numParagraphs; positionIndex++)
            {
                sb.Append("<p>");
                for (int index = 0; index < numSentences; index++)
                {
                    for (int wordIndex = 0; wordIndex < numWords; wordIndex++)
                    {
                        if (wordIndex > 0)
                        {
                            sb.Append(" ");
                        }
    
                        sb.Append(words[rand.Next(words.Length)]);
                    }
                    sb.Append(". ");
                }
                sb.Append("</p>");
            }
    
            return sb.ToString();
        }
    }
    

    In regarding

    and then write the number of a user specified word in the file.

    Will need more details, provide code if you can,.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.