Notes
Notes - notes.io |
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _method11
{
class Program
{
public static readonly Random rnd = new Random();
static public int randomSayi(int a,int b)
{
return rnd.Next(a, b + 1);
}
static public List<int> diziOlustur(List<int> a, int b)
{
for (int i = 0; i < b; i++)
{
int x = randomSayi(1, 100);
a.Add(x);
}
return a;
}
static public List<int> diziYazdir(List<int> a)
{
foreach (var item in a)
{
Console.WriteLine(item);
}
return a;
}
static public int diziElemanlarinitopla(List<int> a)
{
int x = 0;
foreach (var item in a)
{
x += item;
}
return x;
}
static public int enKucukeleman(List<int> a)
{
int x = a[0];
for (int i = 1; i < a.Count-1; i++)
{
if (a[i]<x)
{
x = a[i];
}
}
return x;
}
static public int enBuyukeleman(List<int> a)
{
int x = a[0];
for (int i = 0; i < a.Count - 1; i++)
{
if (a[i] > x)
{
x = a[i];
}
}
return x;
}
static public List<int> tekSayilariyazdir(List<int> a)
{
foreach (var item in a)
{
if (item % 2 != 0)
{
Console.WriteLine(item);
}
}
return null;
}
static public List<int> ciftSayilariyazdir(List<int> a)
{
foreach (var item in a)
{
if (item % 2 == 0)
{
Console.WriteLine(item);
}
}
return null;
}
static public int tekSayilarintoplami(List<int> a)
{
int toplam = 0;
foreach (var item in a)
{
if (item % 2 != 0)
{
toplam += item;
}
}
return toplam;
}
static public int ciftSayilarintoplami(List<int> a)
{
int toplam = 0;
foreach (var item in a)
{
if (item % 2 == 0)
{
toplam += item;
}
}
return toplam;
}
static public List<int> AsalSayilariyazdir(List<int> a)
{
foreach (var item in a)
{
int k = 0;
for (int i = 2; i < a.Count; i++)
{
if (item%i==0)
{
k = 1;
}
}
if (k==0)
{
Console.WriteLine(item);
}
}
return null;
}
static void Main(string[] args)
{
int elemansayisi;
List<int> dizi = new List<int>();
elemansayisi = randomSayi(10, 20);
Console.WriteLine("Eleman sayısı");
Console.WriteLine(elemansayisi);
Console.WriteLine("Dizi");
diziOlustur(dizi, elemansayisi);
diziYazdir(dizi);
Console.WriteLine("Elemanların toplamı");
Console.WriteLine(diziElemanlarinitopla(dizi));
Console.WriteLine("En küçük eleman");
Console.WriteLine(enKucukeleman(dizi));
Console.WriteLine("En büyük eleman");
Console.WriteLine(enBuyukeleman(dizi));
Console.WriteLine("Tek sayılar");
Console.WriteLine(tekSayilariyazdir(dizi));
Console.WriteLine("Çift sayılar");
Console.WriteLine(ciftSayilariyazdir(dizi));
Console.WriteLine("Tek sayıların toplamı");
Console.WriteLine(tekSayilarintoplami(dizi));
Console.WriteLine("Çift sayıların toplamı");
Console.WriteLine(ciftSayilarintoplami(dizi));
Console.WriteLine("Asal sayılar");
Console.WriteLine(AsalSayilariyazdir(dizi));
Console.ReadLine();
}
}
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team