using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace MyMulticastDelegate{ public delegate void MulticastDelegate(int x, int y); public class Vidu2{ public static void Cong(int x, int y) { Console.WriteLine("Ban dang goi phuong thuc Cong()"); Console.WriteLine("{0} + {1} = {2}", x,y,x+y); } public static void Nhan(int x, int y) { Console.WriteLine("Ban dang goi phuong thuc Nhan()"); Console.WriteLine("{0} x {1} = {2}", x, y, x * y); } } class Program{ static void Main(string[] args){ MulticastDelegate del = new MulticastDelegate(Vidu2.Cong); del += new MulticastDelegate(Vidu2.Nhan); Console.WriteLine("Goi dong thoi 2 phuong thuc Cong va Nhan\n\n"); del(7, 6); del -= new MulticastDelegate(Vidu2.Cong); Console.WriteLine("\n\n****Da xoa phuong thuc Cong, chi goi phuong thuc Nhan****\n\n"); del(4, 5); Console.ReadLine(); } } }
Giải thuật sinh đường Ellipse #include <graphics.h>#include <conio.h>#define ROUND(a) ((long)(a+0.5))void plot(int xc, int yc, int x, int y, int color){ putpixel(xc+x, yc+y, color); putpixel(xc-x, yc+y, color); putpixel(xc+x, yc-y, color); putpixel(xc-x, yc-y, color);}void Mid_ellipse(int xc, int yc, int a,…Read More
Code C-C++: Các bài toán xử lý chuỗi (string) - (Phần 2)1. Viết chương trình đổi những kí tự đầu tiên của mỗi từ thành chữ in hoa.void chuhoadau(char *s){ s[0]=toupper(s[0]);while(strstr(s," ")!=NULL){ s=strstr(s," ")+1; s[0]=toupper(s[0]);} }2. Viết chương trình đổi chữ xen kẻ 1 chữ hoa và 1 chữ thường.Ví dụ: nhập ABCDEfgh đổi thành AbCdEfGhvoid chuxenke…Read More
Code C-C++: Các bài toán xử lý chuỗi (string) - (Phần 1)1. Đếm có bao nhiêu khoảng trắng trong chuỗi (string)int demkhoangtrang(char *s){int d=0;while(strstr(s," ")!=NULL){ d++; s=strstr(s," ")+1;}return d;}2. Nhập vào một chuỗi, hãy loại bỏ những khoảng trắng thừa trong chuỗi (string).void xoakhoangtrang(char *s){ char *c=strstr(s," ");…Read More
Các giải thuật sinh đường tròn trong C/C++1. Giải thuật sinh đường tròn Bresenham:void Bre_circle(int xc, int yc, int Radius, int color) { int x, y, p; x = 0; y = Radius; p = 3 - 2 * Radius; while (x <= y) { putpixel(xc + x, yc + y, color); &…Read More
Code C-C++: Các bài toán sử dụng mảng 1 chiềuCác bài toán thao tác với mảng 1 chiều:- Nhập vào 1 dãy số nguyên có n số (1<=n<=100)- In ra màn hình các số lớn hơn 0- Tìm max- Tính tổng các số lớn hơn 10#include<iostream.h> #include<conio.h> void main(){ int a[100],n; // Nhap so phan tu n do{ &nb…Read More
Klik untuk melihat kode: