-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut.cpp
More file actions
120 lines (114 loc) · 2.01 KB
/
tut.cpp
File metadata and controls
120 lines (114 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// #include<iostream>
// using namespace std;
// void square(int *p){
// int a=10;
// p=&a;
// *p = (*p) * (*p);
// cout<<*p<<endl;
// cout<<p<<endl;
// }
// int main(){
// int a = 10;
// square(&a);
// cout<<a<<endl;
// }
/*#include<iostream>
using namespace std;
int factorial(int n){
if(n==0){
return 1;
}
int smalloutput = factorial(n-1);
return n*smalloutput;
}
int main(){
int n;
cin>>n;
int output = factorial(n);
cout<<output<<endl;
}*/
/*#include <iostream>
using namespace std;
int power(int x, int y){
if(y==0)
return 1;
else if(y%2==0)
return power(x,y/2)*power(x,y/2);
else
return x*power(x,y/2)*power(x,y/2);
}
int main(){
int x,y;
cin>>x>>y;
int num = power(x,y);
cout<<num<<endl;
}*/
// #include<iostream>
// using namespace std;
// int num(int n){
// if(n==0)
// return 0;
// while(n>0)
// }
// int main(){
// int n;
// cin>>n;
// int num2 = num(n);
// cout<<num2<<endl;
// }
// #include<iostream>
// using namespace std;
// bool is_sorted(int a[],int size){
// if(size==0 || size==1){
// return true;
// }
// if(a[0]>a[1]){
// return false;
// }
// bool isSmallSorted = is_sorted(a+1,size-1);
// return isSmallSorted;
// }
// int main(){
// int arr[] = {1,2,3,4,5};
// cout<< is_sorted(arr,5)<<endl;
// int arr2[] = {2,3,1,5,8};
// cout<< is_sorted(arr2,5)<<endl;
// }
/* sum of array
#include<iostream>
using namespace std;
int addarr(int a[],int size){
if(size==0||size==1){
return a[0];
}
else{
return a[0]+addarr(a+1,size-1);
}
}
int main(){
int arr[] = {1,2,3,4,5};
cout<< addarr(arr,5)<<endl;
}
*/
/* check number
#include<iostream>
using namespace std;
int arr(int a[],int size,int key)
if(a[0]==key){
return true;
}
else{
int num = arr(a+1,size-1);
return false;
}
int main(){
int size;
int a[size];
cin>>size;
for(int i=0;i<=size;i++){
cin>>a[i];
}
int key;
cin>>key;
cout<<arr(a,size,key)<<endl;
}*/