Testcode für C-Sharp - C++ - Pascal - QBasic
|
|
Zeige Code, welcher mit Umschreibung auch in
anderen Programmiersprachen lauffähig sein müsste. Der Code ist nicht
optimiert, es zeigt nur das Prinzip. |
Eine Zahl auf Prim testen: |
namespace TestGrossePrimzahlen { public partial class Form1 : Form
{ public Form1() { InitializeComponent(); }
private void
button1_Click(object sender, EventArgs e) { int zahltest =
Convert.ToInt32(textBox1.Text);
int test = prim(zahltest);
if(test==0) { textBox2.Text = "Keine"; } else {
textBox2.Text = "Ist eine"; } }
int prim(int n) { int i;
for (i = 2; i <= Math.Sqrt(n); i++) // nach Bentley: Obergrenze = Wurzel
if (n % i == 0) return 0; return 1; } } } |
|
|
|
Julianischer Tag berechnen: |
double JulianischerTag()
{
// Julianischer Tag Berechnen
int intJahrAktuell = DateTime.Now.Year;
int intMonatAktuell = DateTime.Now.Month;
int intTagAktuell = DateTime.Now.Day;
double intStundeAktuell = DateTime.Now.Hour-2;
double intMinuteAktuell = DateTime.Now.Minute;
double intSekundeAktuell = DateTime.Now.Second;
double jd = (1461 * (intJahrAktuell + 4800 + (intMonatAktuell - 14) /
12)) / 4 +
(367 * (intMonatAktuell - 2 - 12 * ((intMonatAktuell - 14) / 12))) / 12
-
(3 * ((intJahrAktuell + 4900 + (intMonatAktuell - 14) / 12) / 100)) / 4
+ intTagAktuell - 32075;
jd = jd + (intStundeAktuell - 12) / 24 + intMinuteAktuell / 1440 +
intSekundeAktuell / 86400;
return jd;
} |
|
Gleichung lösen: |
CLS
DEF fna (x) = 5 * x - 9
DEF fnb (x) = 3 * x + 7
a = 1: s = 1
FOR t = 1 TO 9
FOR i = a TO 1000 STEP s
IF fna(i) > fnb(i) THEN 80
IF fna(i) = fnb(i) THEN 90
NEXT i
80 a = i - s: s = s / 10: NEXT t
90 IF i = 1000 OR i = -.1111111 THEN PRINT " finde keine loesung oder zu
komplex": END
PRINT " x ist wahrscheinlich = "; i |
|
Einfacher Krater in Basic: |
CLS
SCREEN 3
n = 2: ma = 10000: DIM z(320), zz(320)
FOR i = 0 TO 320: zz(i) = 199: NEXT
x(1) = 80: y(1) = 100: q(1) = 1
x(2) = 180: y(2) = 100: q(2) = -1
FOR y = 50 TO 150 STEP 6
FOR x = 1 TO 200
po = 0: FOR i = 1 TO n
r(i) = SQR((x - x(i)) ^ 2 + (y - y(i)) ^ 2): IF r(i) = 0 THEN r(i) = 200
po = po - q(i) / r(i) * 1000: NEXT: IF po > 80 THEN po = 80
IF po < -80 THEN po = -80
IF po > 80 THEN po = 80
po = po + 67 + y / 3
5 IF po > z(x + y / 2) THEN GOSUB 400
10 IF po < zz(x + y / 2) THEN GOSUB 410
NEXT: NEXT
360 GOTO 360
400 IF x = 1 OR x = 319 THEN z(x + y / 2) = po: RETURN
LINE (x + y / 2, 199 - po)-(x - 1 + y / 2, 199 - z(x - 1 + y / 2)), 1:
z(x + y / 2) = po: RETURN
410 IF x = 1 OR x = 319 THEN zz(x + y / 2) = po: RETURN
LINE (x + y / 2, 199 - po)-(x - 1 + y / 2, 199 - zz(x - 1 + y / 2)), 1:
zz(x + y / 2) = po: RETURN |
|
|
CLS : n = 1000: RANDOMIZE TIMER
DIM a(1000)
FOR i = 1 TO n
a(i) = RND(TIMER)
NEXT
min = 32000
max = -32000
FOR i = 1 TO n
IF a(i) < min THEN min = a(i)
IF a(i) > max THEN max = a(i)
NEXT
PRINT max, min |
|
Sinuskurve 1: |
CLS
SCREEN 3
d = 1
DEF fna (x) = SQR(t / 10) * 60 * SIN(x) * EXP(-x / 10) / 2
xu = -1: xo = 20: yu = -2: yo = 2
FOR s = 1 TO 30
FOR i = xu TO xo STEP (xo - xu) / 200
y = fna(i) + s
t = t + 1
PSET (100 + t, 100 + s + y), 1
NEXT
t = 0
NEXT |
|
Sinuskurve 2: |
CLS : CLEAR : SCREEN 3
FOR i = 0 TO 2 * 3.14159265# STEP .065: x = 100 * COS(i): y = 100 *
SIN(i)
LINE (160, 100)-(160 + x, 100 - y), 1: NEXT |
|
Wolke: |
SCREEN 3
FOR R% = 1 TO 50 '** Ausdehnungs-Radius 1-50
FOR i% = 1 TO 10 '** 10 Punkte pro Radius
W = RND * 7 '** Zufalls-Winkel
PSET (150 + R% * SIN(W), 100 + R% * COS(W)), R% AND 7
NEXT i%
NEXT R%
FOR R% = 0 TO 80 '** Wolke von innen nach
'** aussen löschen
CIRCLE (150, 100), R%, 0
CIRCLE (151, 100), R%, 0
t = TIMER: DO: LOOP UNTIL TIMER > t
NEXT R% |
|
Liste Dateiendungen: |
264 3g2 asf asx avi bik dash dat dvr flv h264 m2t m2ts 3dm 3ds 3gp
7z a3d aa aac ace adp ai amr ape apk apng arj asm asp aspx aws bas bat
bbc blend bml bmp btm bzip2 c c4d cab cdr cfm cgi cgm clear clf cmd coff
cpio cpp cpt cs csv dds deb dgn dicom dif dll djvu doc docx dta dvi dwg
dxf edi elf emf eps exe fbx fig flac gif gpx gzip h ha hdr htm html iff
ihtml phtml img inf iso jar java jpe jpeg jpg js jsp lav lha lib lwo lws
lzo lzx m3d ma mac maf max mb md mdf mdl mds mhtml midi mkv ml mmf mng
mod mov mp3 msi mxf nrg obj ods odt ogg out pas pcl pcx pdf pdn php pkg
pl png pos prg prt ps psd py pz3 rar raw rb rib rpm rtf sai sd7 sdxf
sgml sha shtml sldasm sldprt smc smil spr stdf stm stp svg swf sxc tar
tex texinfo tga tgz tif tiff troff txt u3d unity uts vob vsm vue wav wif
wire wlmp wma wmf wmv x x3d xhtml xls xlsx xmi xml xpm xz zip zoo m4v
mp4 mpeg mpg mswmm mts ogv prproj rec rmvb tod tp ts webm 3ga aiff cda
dvf gp4 gp5 logic m4a m4b m4p pcm snd sng uax wpl dib dng dt2 ico icon
pic thm wbmp wdp webp arw cr2 crw dcr fpx mrw nef orf pcd ptx raf rw2
csh drw emz odg sda abr ani cdt fla icns mdi psb pzl sup vsdx 3D 3d dwfx
lcf pro pts skp stl x_t eot otf ttc ttf woff aww chm cnt dbx docm dot
dotm dotx epub ind indd key keynote mht mpp mpt odf ott oxps pages pmd
pot potx pps ppsx ppt pptm pptx prn pub pwi rep sdd sdw shs snp sxw tpl
vsd wpd wps wri xps 1st alx application eng log lrc lst nfo opml plist
reg srt sub tbl text xsd xsl xslt azw azw3 cbr cbz fb2 iba ibooks lit
mobi sdc xlsm accdb accdt mdb mpd one onepkg pst thmx big hi lng pak res
sav save scn scx wotreplay wowpreplay g64 gb gba mbz n64 nds nes rom smd
srm v64 ova ovf pvm vdi vhd vmdk vmem vmwarevm vmx ashx atom bc class
crdownload css dlc download eml gdoc gsheet gslides json part partial
rss torrent xap ldif msg vcf app com cpl gadget lnk scr tmp vbs bin drv
ocx sys vxd 002 003 004 005 006 007 008 009 010 7zip a00 a01 a02 a03 a04
a05 air arc asec bar c00 c01 c02 c03 cso gz hqx inv ipa isz msu nbh rar
r00 r01 r02 r03 r04 r05 r06 r07 r08 r09 r10 sis sisx sit sitd sitx
tar.gz webarchive z01 z02 z03 z04 z05 bak bbb bkf bkp dbk gho ipd
mdbackup nba nbf nbu nco old sbf sbu spb tib wbcat 000 ccd cue daa dao
dmg mdx tao tc toast uif vcd crypt ipsw npf pkpass rem rsc gdb ofx qif
db dbf fdb idx msmessagestore sdf sql sqlite wdb kml kmz map appx
appxbundle blf dump evtx kext mui sfcache swp cnf contact deskthemepack
ics ifo lrtemplate m3u m3u8 pls skn svp template theme themepack trm wba
plugin safariextz xpi inc jad o rc scpt src cfg ini usr dmp ksd pfx ut
adadownload cache temp 3dr cal dct dic gbk md5 prj ref upd upg |