using static System.Console; public class Program { public static void Main() { decimal n; if (!decimal.TryParse(ReadLine(), out n)) return; var resto = (int)(n * 100); WriteLine("NOTAS:"); WriteLine($"{resto / 10000} nota(s) de R$ 100.00"); resto %= 10000; WriteLine($"{resto / 5000} nota(s) de R$ 50.00"); resto %= 5000; WriteLine($"{resto / 2000} nota(s) de R$ 20.00"); resto %= 2000; WriteLine($"{resto / 1000} nota(s) de R$ 10.00"); resto %= 1000; WriteLine($"{resto / 500} nota(s) de R$ 5.00"); resto %= 500; WriteLine($"{resto / 200} nota(s) de R$ 2.00"); WriteLine("MOEDAS:"); resto %= 200; WriteLine($"{resto / 100} moeda(s) de R$ 1.00"); resto %= 100; WriteLine($"{resto / 50} moeda(s) de R$ 0.50"); resto %= 50; WriteLine($"{resto / 25} moeda(s) de R$ 0.25"); resto %= 25; WriteLine($"{resto / 10} moeda(s) de R$ 0.10"); resto %= 10; WriteLine($"{resto / 5} moeda(s) de R$ 0.05"); resto %= 5; WriteLine($"{resto} moeda(s) de R$ 0.01"); } } //https://pt.stackoverflow.com/q/364588/101
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Unit_1 { struct Books { public string title; public float price; public int page; public void getvalues(string t,float pr,int pg) { title =t; price =pr; page =pg; } public void display() { Console.WriteLine("title:{0}",title); Console.WriteLine("price:{0}",price); Console.WriteLine("page:{0}",page); } }; class program { static void main(string[] args) { Books Book1 =new Books(); Books Book2 =new Books(); Book1.getvalues("c programming",600.50,800); Book2.getvalues("c# programming",1000.50,899); Book1.display(); Book2.display(); Console.ReadKey(); } } }
using System; using System.IO; using System.IO.FileStream; namespace FileIOApplication { class Program { static void Main(string[] args) { FileStream F = new FileStream("test.dat", FileMode.OpenOrCreate, FileAccess.ReadWrite); //for (int i = 1; i <= 20; i++) { // F.WriteByte((byte)i); //} int [] data=new int [2] {'A','B'}; int z=data.length; for(int i=0;i<z;i++) { F.WriteByte((byte) data[i]); } F.Position = 0; //for (int i = 0; i <= 20; i++) { // Console.Write(F.ReadByte() + " "); //} int data1=F.ReadByte(); while(data1!=-1) { Console.Write((int)data1 + " "); data1=F.ReadByte(); } F.Close(); Console.ReadKey(); } } }
using System; namespace RectangleApplication { class Rectangle { // member variables double length; double width; public void Acceptdetails() { length = 4.5; width = 3.5; } public double GetArea() { return length * width; } public void Display() { Console.WriteLine("Length: {0}", length); Console.WriteLine("Width: {0}", width); Console.WriteLine("Area: {0}", GetArea()); } } class ExecuteRectangle { static void Main(string[] args) { Rectangle r = new Rectangle(); r.Acceptdetails(); r.Display(); Console.ReadLine(); } } }
using System.IO; using System; class Program { static void Main() { Console.WriteLine("Hello, World!"); } }
using System; namespace ArrayApplication { class MyArray { static void Main(string[] args) { int [] n = new int[10]; /* n is an array of 10 integers */ int i,j; /* initialize elements of array n */ for ( i = 0; i < 10; i++ ) { n[ i ] = i + 100; } /* output each array element's value */ for (j = 0; j < 10; j++ ) { Console.WriteLine("Element[{0}] = {1}", j, n[j]); } Console.ReadKey(); } } }
using System; namespace Tanulas { class IsPrime { static void Main() { TestOperation(); } static int UserInput() { Console.Write("Kérek egy számot: "); int input = int.Parse(Console.ReadLine()); return input; } static void UserOperation() { var input = UserInput(); Prime(input); } static void TestOperation() { var r = new Random(); for (int i = 0; i < 10; i++) { var input = r.Next(1, 100); Prime(input); } } static bool ModCounter(int input) { int mods = 0; int cnt; for (int i = 1; i <= input; i++) { cnt = input % i; if (cnt == 0) { mods++; } } if (mods == 2) { return true; } else { return false; } } static void Prime(int input) { if (ModCounter(input) == true) { Console.WriteLine("!!! " + input + " PRÍMSZÁM !!!"); } else { Console.WriteLine(input + " nem prímszám!"); } } } }
using System.IO; using System; class Program { static void Main() { string phone = "9019441572"; bool IsInternational = !phone.Substring(phone.IndexOf("+"), phone.IndexOf("-") + 1).Equals("+91-"); Console.WriteLine("IsInternational:= "+ IsInternational); } }
using System.IO; using System; class Program { static void Main() { //Show Date DateTime date = new DateTime(2019,02,23); string date1 = date.ToString("M"); string date2 = date.ToString("Y"); string date3 = date.ToString("D"); Console.WriteLine("Date : {0}", date); Console.WriteLine("Date : {0}", date1); Console.WriteLine("Date : {0}", date2); Console.WriteLine("Date : {0}", date3); //Make Substring string str = "Umbrella"; string subStr1 = str.Substring(2,4); string subStr2 = str.Substring(0,6); Console.WriteLine("String : {0}", str); Console.WriteLine("Substring : {0}", subStr1); Console.WriteLine("Substring : {0}", subStr2); //Length of a String Console.WriteLine("String Length : {0}", str.Length); Char[] charArray = str.ToCharArray(); Console.WriteLine("String Length : {0}", charArray.Length); Char[] revCharArray = new Char[charArray.Length]; //Reverse of String revCharArray = charArray; Array.Reverse(revCharArray); string revStr1 = new String(revCharArray); Console.WriteLine("String : {0}", str); Console.WriteLine("Reverse String1 : {0}", revStr1); string revStr2 = ""; int ind = str.Length - 1; while( ind >= 0) { revStr2 += str[ind]; ind--; } Console.WriteLine("Reverse String2 : {0}", revStr2); // Concatenate Strings string fname = "Asif"; string sname = "Kamal"; Console.WriteLine("Full Name : {0}", String.Concat(fname," ",sname)); } }
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more