-
Notifications
You must be signed in to change notification settings - Fork 0
/
Time complexity practice.cpp
37 lines (29 loc) · 1.2 KB
/
Time complexity practice.cpp
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
/*#include<stdio.h>
int main(){
int i,n;
for(int i=-2;i<n;i++)
printf("Hi\n");.............0(n)
//------------------------------------------
for(int i=1;i<=3*n;i++){
printf("Assalamualikum");
}*/ //0(3*n).....0(n) where k=3 and k is constant
//---------------------------------------------------------
/* for (int i = 1; i <= n * n; i++) {
printf("Assalamualaikum\n"); // Corrected: Added newline character............0(n^2)*/
//-----------------------------------------------------------------------------------------------------
/* for (int i = 1; i <= n; i++) { // Outer loop runs n times
for (int j = 1; j <= n; j++) { // Inner loop runs n times
printf("Assalamualaikum\n"); // Print statement, n * n times in total*/ //.......0(n^2)
//-------------------------------------------------------------------------------------
#include <stdio.h>
int main() {
int n=6 ; // Example value for n
for (int i = 1; i <= n; i++) { // Outer loop runs n times
for (int j = 1; j <= i; j++) { // Inner loop runs n times
printf("*"); // Print statement, n * n times in total.......0(n^2)
}
printf("\n");
}
return 0;
}
//