cfrank2000
Well-known member
- Joined
- Mar 6, 2021
- Messages
- 71
- Programming Experience
- Beginner
I don't understand why I can not count the selected characters, please help me, thank you.
C#:
using System;
using System.Collections;
namespace ConsoleApp2karater1
{
class Program
{
struct mystruct{
public char kar;
public int a;
}
static void Main(string[] args)
{
int[] a = new int[12];
int i = 0;
int j = 0;
int k = -1;
int hossz = 0;
char[] tomb = new char[12];
int[] tomb2 = new int[12];
string str1 = "hello world!";
mystruct[] tmb = new mystruct[12];
hossz = str1.Length;
for (i = 0; i < 12; i++)
{
for (j = 0; j < 12; j++)
{
if (str1[j] == str1)
{
a[j] = a[j] + 1;
if (a[j] < 2)
{
//k = k + 1;
tomb = str1;
tomb2 = 1;
k = k + tomb2;
//tmb.kar=str1;
}
else { }
}
}
Console.Write(a+" i " +i+" k "+k+" "+ tomb + " " + tomb2 + " \n");
}
k = 0;
for (i = 0; i < 12; i++)
{
tomb2 = tomb2 + 1;
Console.Write(a + " " + tomb);
Console.Write(" " + tomb2 + "\n");
}
Console.WriteLine("Hello World! ");
}
}
}
Last edited by a moderator: