Show Menu
Cheatography

2035 E2 Cheat Sheet (DRAFT) by

test

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Random Range

rand() % 4 = 0~3
rand() % 11+1 = 1~11

Bubble Sort

7 23 5 78 22
5 7 23 22 78
5 7 22 23 78
5 7 22 23 78

if (list[­walker] < list[w­alker - 1]) {
temp = list[w­alker]; / exchange elements /
list[w­alker] = list[w­alker - 1];
list[w­alker - 1] = temp; }

Initialize 4x5 Array

for(i = 0; i < 4; i ++) { table[­i][0] = i * 20;
for(j = 1; j < 5; j ++) { table[­i][j] = table[i][j - 1] + 1; }; };

MIPS Subroutine

Function Stack

int Foo (int a, int b) { int x; int y = 10;
x = ay+b; return x;}

Complete AF

 

Recursive to Iteration

long factor­ial(int n) { if (n == 0) {
return 1; }
else { return (n * factorial (n-1)); }; }

long factorial (int n) { int i; long fact;
if (n == 0) return 1; else {
for (i = 1, fact = 1; i <= n; i ++) {
fact = fact * i; } return fact; } }

Copy Text

int main(void) {
FILE +fp1, +fp2; int c;
if (!(fp1 = fopen(­“aa­a.dat”, “r”))) {
printf­(“could not open file for reading. \n”); exit; }
if (!(fp2 = fopen(­“bb­b.dat”, “w”))) {
printf­(“could not open file for writing. \n”); exit;}
while ((c = fgetc(­fp1)) != EOF) { fputc(c, fp2); }
fclose­(fp1); fclose­(fp2); return 0; }

Insertion Sort

7 23 5 78 22
7 23 5 78 22
5 7 23 78 22
5 7 23 78 22

if (temp < list[w­alker]) { list[w­alker + 1] = list[w­alker]; walker --; }
else { located = TRUE; };

AF Variables

Complete AF Cont.