0% found this document useful (0 votes)
4 views2 pages

Expanded Coding Cheatsheet

The document is an expanded multi-language coding cheatsheet that provides syntax and examples for common programming tasks in Java, C, C++, and Python. It covers input/output operations, data structures like arrays, lists, maps, sets, and loops, as well as functions, recursion, and object-oriented programming concepts. Each language section includes concise code snippets for quick reference.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Expanded Coding Cheatsheet

The document is an expanded multi-language coding cheatsheet that provides syntax and examples for common programming tasks in Java, C, C++, and Python. It covers input/output operations, data structures like arrays, lists, maps, sets, and loops, as well as functions, recursion, and object-oriented programming concepts. Each language section includes concise code snippets for quick reference.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Expanded Multi-Language Coding Cheatsheet

== Java ==
I/O : Scanner sc = new Scanner([Link]); int a = [Link]();
Array : int[] a = new int[n]; [Link](a);
List : List<Integer> l = new ArrayList<>(); [Link](x); [Link](i); [Link](l);
String : [Link](), [Link](i), [Link](i,j), [Link](t), [Link](" ")
Map : Map<K,V> m = new HashMap<>(); [Link](k,v); [Link](k); [Link](k)
Set : Set<T> s = new HashSet<>(); [Link](x); [Link](x)
Loop : for(int i=0;i<n;i++), for(int x : arr), while(cond)
Func : static int sum(int a,int b){ return a+b; }
Recursion: void solve(int i){ if(i==n)return; solve(i+1); }
OOP : class A { int x; A(int x){this.x = x;} }
Stack : Stack<Integer> st = new Stack<>(); [Link](x); [Link](); [Link]()
Queue : Queue<Integer> q = new LinkedList<>(); [Link](x); [Link]()

== C ==
I/O : scanf("%d", &a); printf("%d", a);
Array : int arr[n]; for(int i=0;i<n;i++) arr[i]=0;
String : char str[100]; gets(str); strlen(str); strcmp(a,b); strcpy(dest, src);
Cond : if, else, switch(x) { case 1: ... }
Loop : for(i=0;i<n;i++), while(cond)
Func : int sum(int a, int b) { return a + b; }
Recursion: void recur(int x) { if(x==0)return; recur(x-1); }
Pointer : int *p = &a; *p = 10;
Struct : struct P { int x, y; }; struct P p1 = {1, 2};

== C++ ==
I/O : cin >> x; cout << x;
Vector : vector<int> v; v.push_back(x); v[i]; sort([Link](), [Link]());
String : string s; [Link](); [Link](i,j); s == t; getline(cin, s);
Map/Set : map<K,V> m; set<T> s; m[k]=v; [Link](x); [Link](k)
Loop : for(int i=0;i<n;i++), for(auto x : v)
Func : int sum(int a,int b){ return a+b; }
Recursion: void recur(int x){ if(x==0)return; recur(x-1); }
Stack : stack<int> s; [Link](x); [Link](); [Link]()
Queue : queue<int> q; [Link](x); [Link](); [Link]()
PriorityQ: priority_queue<int> pq; [Link](x); [Link](); [Link]()

== Python ==
I/O : a = int(input()); s = input(); print(a, s)
List : a = [0]*n; [Link](x); [Link](); a[i]; len(a)
String : s[0], s[1:3], len(s), s == t, [Link](), [Link]()
Dict : d = {}; d[k] = v; [Link](k); k in d; del d[k]
Set : s = set(); [Link](x); x in s
Loop : for i in range(n):, for x in arr:, while cond:
Func : def sum(a,b): return a + b
Recursion: def recur(x): if x==0: return; recur(x-1)
Stack : st = []; [Link](x); [Link]()
Queue : from collections import deque; q = deque(); [Link](x); [Link]()
Heap : import heapq; [Link](h, x); [Link](h)

You might also like