diff --git a/Milestone-17(a)/problem-01-17(a)- recursion -w3resource.cpp b/Milestone-17(a)/problem-01-17(a)- recursion -w3resource.cpp new file mode 100644 index 00000000..89aacf8f --- /dev/null +++ b/Milestone-17(a)/problem-01-17(a)- recursion -w3resource.cpp @@ -0,0 +1,17 @@ +#include +using namespace std; +void print(int n) +{ + if(n==1) + { + cout< +using namespace std; +int add(int n) +{ + int sum=0; + if(n==1 || n==0) + { + return n; + } +// add(n-1); + sum=n+add(n-1); + return sum; +} +int main() +{ + int n; + cout<<"enter n-"<>n; + int x=add(n); + cout<<"addition- "< +using namespace std; +void print(int arr[],int index,int size) +{ + if(index>=size) + { + return ; + } + cout< +using namespace std; +void print(int arr[],int index,int size) +{ + if(index>=size) + { + return ; + } + cout< +using namespace std; +int counter=0; +int count_digits(int n) +{ + + if(n!=0) // if(n<10) + { // return 1; + counter++; // else + count_digits(n/10); // return 1+count_digits(n/10); + } + return counter; +} +int main() +{ + int n; + cout<<"enter n - "<>n; + int x=count_digits(n); + cout<<"no of digits - "< +using namespace std; +int sum=0; +int sum_of_digits(int n) +{ + if(n==0) + { + return 0; + + } + return n%10+sum_of_digits(n/10); +} +int main() +{ + int n; + cin>>n; + cout<<"sum of digits- "< + +using namespace std; +int gcd(int n1,int n2,int val) +{ + cout<<"d"<1) + { + cout<<"s"<>n1; + cout<<"enter second number"<>n2; + int val; + if(n1>n2) + { + val=n1; + } + else{ + val=n2; + } + int x=gcd(n1,n2,val); + cout<<"GCD of"< +using namespace std; +int func(int arr[],int index,int size,int &max) + { + if(index < size) + { + if(max +#include +using namespace std; +void print(string s,int index) +{ + if(index>s.size()) + { + return; + } + print(s,index+1); + cout<>s; + print(s,0); + +} diff --git a/Milestone-17(a)/problem-10-17(a).cpp b/Milestone-17(a)/problem-10-17(a).cpp new file mode 100644 index 00000000..68079b21 --- /dev/null +++ b/Milestone-17(a)/problem-10-17(a).cpp @@ -0,0 +1,20 @@ +#include +using namespace std; +int fact(int n) +{ + if(n==0 ||n==1) + { + return n; + } + else + { + return n*fact(n-1); + } +} +int main() +{ + int n; + cout<<"enter number - "<>n; + cout<<"factorial of "< +using namespace std; + +long convert_binary(int n) +{ +// static long bin,rem,fact=1; + static long bin,rem,fact=1; +cout<<"statcic bin -"<>n; + cout<<"binary number - "< +using namespace std; +int count=0; +bool prime(int ind,int n) +{ + if(ind>n; + prime(2,n); + if (count==0) + { + cout<<"prime number"< +using namespace std; +void print(int val,int n) +{ +if(val>n) +{ + return; +} +cout<>n; + cout<<"printing even numbers- "; + print(2,n); + cout< +#include +using namespace std; +string palindrome(char s1[],int size,int index) +{ + static string s2; + if(index>=size) + { + return s2; + } + + palindrome(s1,size,index+1); + s2+=s1[index]; + return s2; + +} +int main() +{ + char s1[20]; + string s; + cout<<"enter any string "<>s1; + int size=strlen(s1); + s=palindrome(s1,size,0); + if(s1==s) + cout<<"yes"; + else + cout<<"no"; +} diff --git a/Milestone-17(a)/problem-17-17(a).cpp b/Milestone-17(a)/problem-17-17(a).cpp new file mode 100644 index 00000000..35b02d55 --- /dev/null +++ b/Milestone-17(a)/problem-17-17(a).cpp @@ -0,0 +1,32 @@ +#include +using namespace std; +int pow(int x,int p) +{ + if(p==0) + { + return 0; + } + else if(p==1) + { + return x; + } + else + { + if(p%2==0) + { + int y=pow(x,p/2); + return y*y; + } + else + return pow(x,p-1); + } +} +int main() +{ + int x,p; + cout<<"enter number whose power needs to be calculated"<>x; + cout<<"enter power - "; + cin>>p; + cout<<"ans- "< +using namespace std; +string copystring(string s1,int index,int size) +{ + static string s2=""; + if(index>=size) + { + return s2; + } + else + { + s2=s2+s1[index]; + copystring(s1,index+1,size); + } + return s2; +} +int main() +{ + string s1; + cout<<"enter string"<>s1; + string s=copystring(s1,0,s1.size()); + cout<<"copied string - "< +#include +using namespace std; +int func(string s1,int size,int index) +{ + if(index>=size) + { + return -1; + } + else + { + if(isupper(s1[index])) + { + return index; + } + else + { + return func(s1,size,index+1); + } + } +} +int main() +{ + string s1; + cout<<"enter string - "< +using namespace std; +int binarysearch(int arr[],int size,int start,int end,int ele) +{ + int c=0; + if(start<=end) + { + int mid=(start+end)/2; + + if(arr[mid]==ele) + { + c=mid; + } + else if(ele>ele; + int x=binarysearch(arr,size,0,size-1,ele); + cout<<"element found at - "< +using namespace std; +int main() +{ + cout<<"Welcome to Girl Code It"; +} diff --git a/Sejal Chanchlani/Milestone-01/Problem-02.cpp b/Sejal Chanchlani/Milestone-01/Problem-02.cpp new file mode 100644 index 00000000..7043803c --- /dev/null +++ b/Sejal Chanchlani/Milestone-01/Problem-02.cpp @@ -0,0 +1,18 @@ +#include +using namespace std; +int main() +{ + int a,b; + cout<<"enter first number"<>a; + cout<<"enter second number"<>b; + if(a>b) + { + cout< +using namespace std; +int main() +{ + int a,b; + cout<<"enter any number"<>a; + if(a%2==0) + { + cout< +using namespace std; +int main() +{ + int a,b; + cout<<"enter any number"<>a; + if(a==0) + { + cout<0) + { + cout< +using namespace std; +int main() +{ + int a,b; + cout<<"enter first number"<>a; + cout<<"enter second number"<>b; + cout<<"Multiplication of "< +using namespace std; +int main() +{ + int n,i=1; + cout<<"enter n"<>n; + while(n) + { + cout< +using namespace std; +int main() +{ + int n; + cout<<"enter n"<>n; + while(n) + { + cout< +using namespace std; +int main() +{ + int i=0; + while(i!=100) + { + if(i%2==0) + { + cout< +using namespace std; +int main() +{ + int i=100; + while(i!=0) + { + if(i%2!=0) + { + cout< +using namespace std; +int main() +{ + int i=1,sum=0; + int n; + cout<<"enter n"<>n; + while(i!=n) + { + sum=sum+i; + i++; + } + cout<<"sum="< +using namespace std; +int main() +{ + int n; + cout<<"enter n"<>n; + int i=1,sum=0; + while(i!=n) + { + if(i%2==0) + { + sum=sum+i; + } + i++; + } + cout<<"sum="< +using namespace std; +int main() +{ + int n; + cout<<"enter n"<>n; + int i=1,sum=0; + while(i!=n) + { + if(i%2!=0) + { + sum=sum+i; + } + i++; + } + cout<<"sum="< +using namespace std; +int main() +{ + int n; + cout<<"enternumber twhose table nededs to be printed"<>n; + for(int i=1;i<=10;i++) + { + cout<>n; + while(n!=0) + { + r=n%10; + count++; + n=n/10; + } + cout<<"no of digits= "< +using namespace std; +int main() +{ + char i; + for(i='a';i<='z';i++) + { + cout< +using namespace std; +int main() +{ + long long int n,r; + cout<<"enter number"<>n; + r=n%10; + cout<<"last digit = "<>n; + r1=n%10; + cout<<"last digit = "<>n; + while(n!=0) + { + sum=sum+n%10; + n=n/10; + + } + cout<<" sum = "< +using namespace std; +int main() +{ + long long int n,prod=1; + cout<<"enter number"<>n; + while(n!=0) + { + prod=prod*(n%10); + n=n/10; +} +cout<<" prod = "< +using namespace std; +int main() +{ + long long int n,r,sum=0; + cout<<" enter number "<>n; + while(n!=0) + { + r=n%10; + sum=sum*10+r; + n=n/10; + } + cout<<"reverse number - "< +using namespace std; +int main() +{ + long long int n,temp,r,sum=0; + cout<<" enter number "<>n; + temp=n; + + while(n!=0) + { + r=n%10; + sum=sum*10+r; + n=n/10; + } + if(temp==sum) + { + cout<<"palindrome number"< +using namespace std; +int main() +{ + long long int n,ele,temp,r,count=0; + cout<<" enter number "<>n; + temp=n; + cout<<"enter digit whose frequency needs to be found out "<>ele; + while(n!=0) + { + r=n%10; + if(ele==r) + { + count++; + } + n=n/10; + } + cout<<"count of digit = "< +using namespace std; +int main() +{ + int n=1; + for(int i=0;i<=225;i++) + { + cout<<"ASCII Value of "<<(char)i<<" is "< +using namespace std; +int main() +{ + int n,p; + long long int x=1; + cout<<"enter number whose power needs to be calculated"<>n; + cout<<"enter power"<>p; + while(p) + { + x=x*n; + p--; + } + cout<<"ans= "< +using namespace std; +int main() +{ + + long long int num,fact=1; + cout<<"enter number whose factorial needs to be calculated"<>num; + while(num) + { + fact=fact*num; + num--; + } + cout<<" factorial = "< +using namespace std; +int main() +{ + long long int num1,num2,hcf=1,min; + cout<<"enter first number"<>num1; + cout<<"enter second number"<>num2; + min=(num1>num1; + cout<<"enter second number"<>num2; + max=(num1>num; + for(int i=1;i<=num;i++) + { + if(num%i==0) + { + cout< +using namespace std; +int main() +{ + int n,count=0; + cout<<"enter number"<>n; + for(int i=2;i<=n-1;i++) + { + if(n%i==0) + { + count=1; + break; + } + } + if(count==1) + { + cout<<"number is non-prime"< +using namespace std; +int main() +{ + int n,i=2,count=0; + cout<<"enter number"<>n; + while(i!=n) + { + for(int j=2;j<=i-1;j++) + { + if(i%j==0) + { + count=1; + break; + } + } + if(count!=1) + { + cout< +using namespace std; +int main() +{ + int n,i=2,count=0,sum=0; + cout<<"enter number"<>n; + while(i!=n) + { + for(int j=2;j<=i-1;j++) + { + if(i%j==0) + { + count=1; + break; + } + } + if(count!=1) + { + sum=sum+i; + } + count=0; + i++; + + } + cout<<" sum of all prime numbers between 1 and "< +using namespace std; +int main() +{ + int n,i=2,count=0,sum=0; + cout<<"enter number"<>n; + for(int i=2;i<=n;i++) + { + if(n%i==0) + { + for(int j=2;j<=i-1;j++) + { + if(i%j==0) + { + count=1; + break; + } + } + if(count!=1) + { + cout< +using namespace std; +int main() +{ + int r,n,sum=0,temp; + cout<<"enter number"<>n; + temp=n; + while(n!=0) + { + r=n%10; + sum=sum+(r*r*r); + n=n/10; + } + if(sum==temp) + { + cout< +using namespace std; +int main() +{ + int n,i=1,temp,r,count=0,sum=0; + cout<<"enter limit"<>n; + while(i!=n) + { + temp=i; + sum=0; + while(temp!=0) + { + r=temp%10; + sum=sum+(r*r*r); + temp=temp/10; + } + if(sum==i) + { + cout< +using namespace std; +int main() +{ + int n,temp,sum=0; + cout<<"enter number"<>n; + temp=n; + for(int i=1;i<=n/2;i++) + { + if(n%i==0) + { + cout< +using namespace std; +int main() +{ + int n,temp,sum=0,i=1; + cout<<"enter number"<>n; + while(i!=n) + { + temp=i; + sum=0; + for(int j=1;j<=temp/2;j++) + { + if(temp%j==0) + { + sum=sum+j; + } + } + if(sum==temp) + { + cout< +using namespace std; +int main() +{ + int n,temp,fact,r,sum=0; + cout<<"enter number"<>n; + temp=n; + while(n!=0) + { + fact=1; + r=n%10; + while(r!=0) + { + fact=fact*r; + r--; + } + sum=sum+fact; + n=n/10; + + } + if(temp==sum) + { + cout< +using namespace std; +int main() +{ + int n,temp,fact,r,sum=0,i=1; + cout<<"enter number"<>n; + while(i!=n) + { + temp=i; + sum=0; + fact=1; + while(temp!=0) + { + r=temp%10; + fact=1; + + while(r!=0) + { + fact=fact*r; + r--; + } + + sum=sum+fact; + temp=temp/10; + } + if(sum==i){ + cout< +using namespace std; +int main() +{ + int n,n1=0,n2=1,n3; + cout<<"enter number"<>n; + cout< +#define size 6 +using namespace std; +int main() +{ + + char binary[size+1],comp[size+1]; + cout<<"enter"<>binary; + for(int i=0;i<=size;i++) + { + if(binary[i]=='0') + { + comp[i]='1'; + } + else if(binary[i]=='1') + { + comp[i]='0'; + } + else + cout<<"enter valid binary number"< +#define SIZE 6 +using namespace std; +int main() +{ + char binary[SIZE+1],ones[SIZE+1],twos[SIZE+1]; + cout<<"enter "<>binary; + for(int i=0;i<=SIZE;i++) + { + if(binary[i]=='1') + { + ones[i]='0'; + } + else if(binary[i]=='0') + { + ones[i]='1'; + } + } + char carry='1'; + for(int i=SIZE;i>=0;i--) + { + if(ones[i]=='1' && carry=='1') + { + twos[i]='0'; + carry='1'; + } + else if(ones[i]=='0' && carry=='1') + { + twos[i]='1'; + carry='0'; + } + else + { + twos[i]=ones[i]; + } + + } + cout<<" Binary string = "<>binary; + temp=binary; + while(temp!=0) + { + r=temp%1000; + for(int i=0;i<8;i++) + { + if(r==mat[i]) + { + octal=octal+(i*place); + break; + } + } + place=place*10; + temp=temp/1000; + } + cout<<"Octal number - "< +#include +using namespace std; +int main() +{ + long long binary; + int i=0,rem,sum=0; + cout<<"Enter binary number - "<>binary; + while(binary!=0) + { + rem=binary%10; + sum=sum+rem*(pow(2,i)); + i++; + binary=binary/10; + } + cout<<" Decimal number - "< +#include +using namespace std; +int main() +{ + long long binary,temp; + int index=0,r; + cout<<"enter binary number - "<>binary; + temp=binary; + int mat[] = {0, 1, 10, 11, 100, 101, 110, 111, 1000, + 1001, 1010, 1011, 1100, 1101, 1110, 1111}; + char hexa[20]; + while(temp!=0) + { + r=temp%10000; + for(int i=0;i<16;i++) + { + if(r==mat[i]) + { + if(i<10) + { + hexa[index]=(char)(48+i); + } + else + { + hexa[index]=(char)(65+(i-10)); + } + index++; + break; + } + } + temp=temp/10000; + } + hexa[index]='\0'; + cout< +using namespace std; +int main() +{ + int mat[]={0,1,10,11,100,101,110,111}; + int octal,temp,rem,place=1; + long long binary=0; + cout<<"enter octal number - "<>octal; + temp=octal; + while(temp!=0) + { + rem=temp%10; + binary=(mat[rem]*place)+binary; + temp=temp/10; + place=place*1000; + } + cout<<"binary - "< +#include +using namespace std; +int main() +{ + int octal,temp,dec=0,i=0,r; + cout<<"enter octal number -"<>octal; + temp=octal; + while(temp!=0) + { + r=temp%10; + dec=dec+(r*pow(8,i)); + i++; + temp=temp/10; + } + cout<<"octal number - "< +#include +using namespace std; +int main() +{ + int mat[] = {0, 1, 10, 11, 100, 101, 110, 111, 1000, + 1001, 1010, 1011, 1100, 1101, 1110, 1111}; + int octal,temp,place=1,binary=0,r; + cout<<"enter octal number"<>octal; + temp=octal; + int index=0; + char hexa[20]; + while(temp!=0) + { + r=temp%10; + binary=(mat[r]*place)+binary; + place=place*1000; + temp=temp/10; + } + //cout<<"hexadecimal number - "< +#include +using namespace std; +int main() +{ + int decimal,temp,index=0; + cout<<"enter decimal number"<>decimal; + temp=decimal; + char binary[65]; + while(temp>0) + { + binary[index]=temp%2+'0'; + cout< +using namespace std; +int main() +{ + int decimal,octal,temp,r,place=1; + cout<<"enter decimal number"<>decimal; + temp=decimal; + while(temp>0) + { + r=temp%8; + octal=(place*r)+octal; + place=place*10; + temp=temp/8; + } + cout<<"octal number - "< +#include +using namespace std; +int main() +{ + char mat[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; + int r; + int decimal,temp,index=0; + cout<<"enter decimal number"<>decimal; + temp=decimal; + char hexa[65]; + while(temp>0) + { + r=temp%16; + hexa[index]=mat[r]; + index++; + temp=temp/16; + } + hexa[index]='\0'; + strrev(hexa); + cout<<"Hexadecimal - "< +#include +using namespace std; +int main() +{ + char hex[17]; + char bin[65] ="" ; + int i = 0,index=0; + + /* Input hexadecimal number from user */ + + cout<<"Enter any hexadecimal number: "; + cin>>hex; + + /* Extract first digit and find binary of each hex digit */ + for(i=0; hex[i]!='\0'; i++) + { + switch(hex[i]) + { + case '0': + strcat(bin, "0000"); + + break; + case '1': + strcat(bin, "0001"); + + break; + case '2': + strcat(bin, "0010"); + + break; + case '3': + strcat(bin, "0011"); + + break; + case '4': + strcat(bin, "0100"); + + break; + case '5': + strcat(bin, "0101"); + + break; + case '6': + strcat(bin, "0110"); + + break; + case '7': + strcat(bin, "0111"); + + break; + case '8': + strcat(bin, "1000"); + + break; + case '9': + strcat(bin, "1001"); + + break; + case 'a': + case 'A': + strcat(bin, "1010"); + + break; + case 'b': + case 'B': + strcat(bin, "1011"); + + break; + case 'c': + case 'C': + strcat(bin, "1100"); + + break; + case 'd': + case 'D': + strcat(bin, "1101"); + + break; + case 'e': + case 'E': + strcat(bin, "1110"); + + break; + case 'f': + case 'F': + strcat(bin, "1111"); + + break; + default: + cout<<"Invalid hexadecimal input."<>hex; + long decimal,val; + int len=strlen(hex); + len--; + for(int i=0;hex[i]!='\0';i++) + { + if(hex[i]>='0' && hex[i]<='9') + { + val = hex[i] - 48; + } + else if(hex[i]>='a' && hex[i]<='f') + { + val = hex[i] - 97 + 10; + } + else if(hex[i]>='A' && hex[i]<='F') + { + val = hex[i] - 65 + 10; + } + + decimal += val * pow(16, len); + len--; + } + + int octal=0,place=1,r; + while(decimal!=0) + { + r=decimal%8; + octal=(r*place)+octal; + decimal=decimal/8; + place=place*10; + } + cout<<"Octal- "< +#include +#include +using namespace std; +int main() +{ + char hex[65]; + cout<<"enter hexadecimal number"<>hex; + int len=strlen(hex); + len--; + int val,decimal=0; + for(int i=0;hex[i]!='\0';i++) + { + if(hex[i]>='0' && hex[i]<='9') + { + val=hex[i]-48; + } + else if(hex[i]>='a' && hex[i]<='f') + { + val = hex[i] - 97 + 10; + } + else if(hex[i]>='A' && hex[i]<='F') + { + val = hex[i] - 65 + 10; + } + + decimal += val * pow(16, len); + len--; + } + cout<<"decimal number -"< +using namespace std; +int add(int a, int b) +{ + return a+b; +} +int main() +{ + int x,y; + cout<<"enter first number"<>x; + cout<<"enter second number"<>y; + int z=add(x,y); + cout<<"addition of two numbers is "< +using namespace std; +int product(int a,int b) +{ + return a*b; +} +int main() +{ + int x,y,z; + cout<<"enter first number"<>x; + cout<<"enter second number"<>y; + z=product(x,y); + cout<<"product of"< +using namespace std; +double area(double r) +{ + return 3.14*r*r; +} +double circ(double r) +{ + return 2*3.14*r; +} +int main() +{ + double r,x,y; + cout<<"enter radius"<>r; + x=area(r); + cout<<"Area = "<>x; + cout<<"enter second number"<>y; + cout<<"enter third number"<>z; + g=max(x,y,z); + h=min(x,y,z); + cout<<"Maximum = "<>x; + fun(x); + +} diff --git a/Sejal Chanchlani/Milestone-10/problem-06-10.cpp b/Sejal Chanchlani/Milestone-10/problem-06-10.cpp new file mode 100644 index 00000000..ce3ec305 --- /dev/null +++ b/Sejal Chanchlani/Milestone-10/problem-06-10.cpp @@ -0,0 +1,21 @@ +//problem-06-10 +#include +using namespace std; +void age(int x) +{ + if(x>=18) + { + cout<<"You are eligible to vote"<>x; + age(x); +} diff --git a/Sejal Chanchlani/Milestone-10/problem-07-10.cpp b/Sejal Chanchlani/Milestone-10/problem-07-10.cpp new file mode 100644 index 00000000..448d554d --- /dev/null +++ b/Sejal Chanchlani/Milestone-10/problem-07-10.cpp @@ -0,0 +1,29 @@ +//problem-07-10 +#include +using namespace std; +void prime(int x) +{ + int count=0; + for(int i=2;i>x; + prime(x); + +} diff --git a/Sejal Chanchlani/Milestone-10/problem-08-10.cpp b/Sejal Chanchlani/Milestone-10/problem-08-10.cpp new file mode 100644 index 00000000..924c1f35 --- /dev/null +++ b/Sejal Chanchlani/Milestone-10/problem-08-10.cpp @@ -0,0 +1,42 @@ +//problem-07-10 +#include +using namespace std; +void marks(int x) +{ + if(x>=91 && x<=100) + { + cout<<"ft"<=81 && x<=90) + { + cout<<"lk"<=71 && x<=80) + { + cout<<"Grade - "<<"BB"<=61 && x<=70) + { + cout<<"Grade - "<<"BC"<=51 && x<=60) + { + cout<<"Grade - "<<"CD"<=41 && x<=70) + { + cout<<"Grade - "<<"DD"<>x; +marks(x); +} diff --git a/Sejal Chanchlani/Milestone-10/problem-09-10.cpp b/Sejal Chanchlani/Milestone-10/problem-09-10.cpp new file mode 100644 index 00000000..9584a02b --- /dev/null +++ b/Sejal Chanchlani/Milestone-10/problem-09-10.cpp @@ -0,0 +1,20 @@ +//problem-08-10 +#include +using namespace std; +int factorial(int x) +{ + int fact=1; + while(x) + { + fact=fact*x; + x--; + } + return fact; +} +int main() +{ + int x; + cout<<"enter number"<>x; + cout<<"factorial of "< +using namespace std; +int cube(int x) +{ + return x*x*x; +} +int main() +{ + int x; + cout<<"enter x"<>x; + int n=cube(x); + cout<<"cube of "< +using namespace std; +double dia(double r) +{ + return 2*r; +} +double circum(double r) +{ + return 2*3.14*r; +} +double area(double r) +{ + return 3.14*r*r; +} +int main() +{ + double r; + cout<<"enter radius"<>r; + cout<<"Diameter of circle is "< +using namespace std; +void fun(int x,int y) +{ + if(x>y) + { + cout<>x; + cout<<"enter second number"<>y; + fun(x,y); + +} diff --git a/Sejal Chanchlani/Milestone-10/problem-13-10.cpp b/Sejal Chanchlani/Milestone-10/problem-13-10.cpp new file mode 100644 index 00000000..f8d9e004 --- /dev/null +++ b/Sejal Chanchlani/Milestone-10/problem-13-10.cpp @@ -0,0 +1,65 @@ +//problem-13-10 +#include +using namespace std; +void prime(int x) +{ + int count=0; + for(int i=2;i>x; + prime(x); + perfect(x); + armstrong(x); +} diff --git a/Sejal Chanchlani/Milestone-10/problem-14-10.exe b/Sejal Chanchlani/Milestone-10/problem-14-10.exe new file mode 100644 index 00000000..71c4edb2 Binary files /dev/null and b/Sejal Chanchlani/Milestone-10/problem-14-10.exe differ diff --git a/Sejal Chanchlani/Milestone-10/problem-15-10.cpp b/Sejal Chanchlani/Milestone-10/problem-15-10.cpp new file mode 100644 index 00000000..1a745a87 --- /dev/null +++ b/Sejal Chanchlani/Milestone-10/problem-15-10.cpp @@ -0,0 +1,31 @@ +//problem-15-10 +#include +using namespace std; +void armstrong(int a,int b) +{ + int sum=0,r,temp; + for(int i=b;i>a; + cout<<"enter lower limit"<>b; + armstrong(a,b); +} diff --git a/Sejal Chanchlani/Milestone-10/problem-16-10.cpp b/Sejal Chanchlani/Milestone-10/problem-16-10.cpp new file mode 100644 index 00000000..05d0f12e --- /dev/null +++ b/Sejal Chanchlani/Milestone-10/problem-16-10.cpp @@ -0,0 +1,31 @@ +//problem-16-10 +#include +using namespace std; +void perfect(int a,int b) +{ + int sum; + for(int i=b;i<=a;i++) + { + for(int j=1;j>a; + cout<<"enter lower limit"<>b; + perfect(a,b); +} diff --git a/Sejal Chanchlani/Milestone-11/problem-01-11.cpp b/Sejal Chanchlani/Milestone-11/problem-01-11.cpp new file mode 100644 index 00000000..7198a43f --- /dev/null +++ b/Sejal Chanchlani/Milestone-11/problem-01-11.cpp @@ -0,0 +1,17 @@ +//problem-01-11 +#include +using namespace std; +int main() +{ + int arr[10]; + for(int i=0;i<10;i++) + { + cout<<"enter "<>arr[i]; + } + for(int i=0;i<10;i++) + { + + cout< +using namespace std; +int main() +{ + int arr[10]; + for(int i=0;i<10;i++) + { + cout<<"enter "<>arr[i]; + } + for(int i=0;i<10;i++) + { + + cout<>x; + for(int i=0;i<10;i++) + { + if(x==arr[i]) + { + cout<<"element found at "< +using namespace std; +int main() +{ + int arr[10],brr[10]; + for(int i=0;i<10;i++) + { + cout<<"enter "<>arr[i]; + } + for(int i=0;i<10;i++) + { + + cout< +using namespace std; +int main() +{ + int arr[10],sum=0,prod=1; + for(int i=0;i<10;i++) + { + cout<<"enter "<>arr[i]; + sum=sum+arr[i]; + prod=prod*arr[i]; + } + for(int i=0;i<10;i++) + { + + cout<>n; + int arr[n]; + for(int i=0;i>arr[i]; + } + max=arr[0],min=arr[0]; + for(int i=0;i=arr[i]) + { + min=arr[i]; + } + } + cout<<"Minimum element - "< +using namespace std; +int main() +{ + int n; + cout<<"enter array size"<>n; + int arr[n]; + for(int i=0;i>arr[i]; + } + for(int i=0;i +using namespace std; +int main() +{ + int arr[10],brr[5]; + for(int i=0;i<10;i++) + { + cin>>arr[i]; + } + int j=5; + for(int i=0;i<5;i++) + { + brr[i]=arr[j]; + j++; + } + for(int i=0;i<5;i++) + { + cout< +using namespace std; +int main() +{ + int n,sum=0,prod=1,max,min; + cout<<"enter size of array"<>n; + int arr[n]; + for(int i=0;i>arr[i]; + sum=sum+arr[i]; + prod=prod*arr[i]; + } + max=arr[0]; + min=arr[0]; + for(int i=0;i=arr[i]) + { + min=arr[i]; + } + } + cout<<"sum = "< +using namespace std; +int main() +{ + int n; + cout<<"enter size of array"<>n; + int arr[n]; + for(int i=0;i>arr[i]; + } + for(int i=0;i=0;i--) + { + arr[i]=arr[i-1]; + } + arr[0]=temp; + for(int i=0;i +using namespace std; +int main() +{ + int n; + int max,temp; + cout<<"enter size"<>n; + int arr[n]; + for(int i=0;i>arr[i]; + } + for(int i=0;iarr[j]) + { + temp=arr[i]; + arr[i]=arr[j]; + arr[j]=temp; + } + } + } + for(int i=0;i +using namespace std; +int main() +{ + int n,temp,r,sum=0; + cout<<"enter number"<>n; + temp=n; + while(temp!=0) + { + r=temp%10; + sum=sum+r; + temp=temp/10; + } + cout<<"sum of digits of number is "< +using namespace std; +int main() +{ + int n; + cout<<"enter size"<>n; + int arr[n]; + for(int i=0;i>arr[i]; + } + for(int i=0;i +using namespace std; +int main() +{ + int n; + cout<<"enter size"<>n; + int arr[n]; + for(int i=0;i>arr[i]; + } + for(int i=0;i +using namespace std; +int main() +{ + int n; + cout<<"enter size"<>n; + int arr[n]; + for(int i=0;i>arr[i]; + } + for(int i=0;i +using namespace std; +int main() +{ + int n; + cout<<"enter size"<>n; + int arr[n]; + for(int i=0;i>arr[i]; + } + for(int i=0;i +using namespace std; +int main() +{ + int n; + cout<<"enter size"<>n; + int arr[n]; + for(int i=0;i>arr[i]; + } + for(int i=0;i>x; + cout<<"enter the position "<>pos; + for(int i=n;i>=n-pos;i--) + { + arr[i]=arr[i-1]; + } + arr[pos]=x; + for(int i=0;i +using namespace std; +int main() +{ + int n; + cout<<"enter size"<>n; + int arr[n]; + for(int i=0;i>arr[i]; + } + for(int i=0;i>pos; + for(int i=pos-1;i +using namespace std; +int main() +{ + int n; + cout<<"enter size "<>n; + int arr[n],brr[n]; + for(int i=0;i>arr[i]; + brr[i]=-1; + } + for(int i=0;i +using namespace std; +int main() +{ + int n; + cout<<"enter size "<>n; + int arr[n],brr[n]; + for(int i=0;i>arr[i]; + brr[i]=-1; + } + for(int i=0;i +using namespace std; +int main() +{ + int n; + cout<<"enter size"<>n; + int arr[n],brr[n],crr[n+n]; + cout<<"enter elements of first array"<>arr[i]; + } + for(int i=0;i>brr[i]; + } + for(int i=0;i +using namespace std; +int main() +{ + int n; + cout<<"enter array size "<>n; + int arr[n]; + for(int i=0;i>arr[i]; + } + for(int i=0;i +using namespace std; +int main() +{ + int n,temp,j; + cout<<"enter size"<>n; + j=n-1; + int arr[n]; + for(int i=0;i>arr[i]; + } + for(int i=0;i +using namespace std; +int main() +{ + int n; + cout<<"enter size"<>n; + int arr[n]; + for(int i=0;i>arr[i]; + } + for(int i=0;i>ele; + for(int i=0;i +using namespace std; +int main() +{ + int n; + cout<<"enter array size"<>n; + int arr[n]; + for(int i=0;i>arr[i]; + } + for(int i=0;iarr[j]) + { + temp=arr[j]; + arr[j]=arr[i]; + arr[i]=temp; + } + } + } + cout<<"after sorying in ascending order - "< +using namespace std; +int main() +{ + int n; + cout<<"enter size "<>n; + int arr[n]; + for(int i=0;i>arr[i]; + } + for(int i=0;i>k; + while(k) + { + + temp=arr[0]; + for(int i=0;i +using namespace std; +int main() +{ + int n; + cout<<"enter size "<>n; + int arr[n]; + for(int i=0;i>arr[i]; + } + for(int i=0;i>k; + while(k) + { + */ + int temp=arr[n-1]; + for(int i=n-1;i>=0;i--) + { + arr[i]=arr[i-1]; + } + arr[0]=temp; + //k--; +//} + cout<<"after right rotation "< +using namespace std; +void input_elements(int *a,int n,int m) +{ + for(int i=0;i>*((a+i*n)+j); + } + } +} +void display(int *a,int n,int m) +{ + for(int i=0;i>n; + cout<<"enter columns - "<>m; + int a[n][m]; + cout<<"1- Sum of all elements of matrix of size m x n"<>choice; + input_elements((int *)a,n,m); + display((int *)a,n,m); + switch(choice) + { + + case 1: + { + sum_matrix((int *)a,n,m); + break; + } + case 2: + { + sum_row((int *)a,n,m); + break; + } + case 3: + { + sum_column((int *)a,n,m); + break; + } + case 4: + { + transpose((int *)a,n,m); + break; + } + } + + +} diff --git a/Sejal Chanchlani/Milestone-12/problem-02-12.cpp b/Sejal Chanchlani/Milestone-12/problem-02-12.cpp new file mode 100644 index 00000000..45fe058b --- /dev/null +++ b/Sejal Chanchlani/Milestone-12/problem-02-12.cpp @@ -0,0 +1,49 @@ +//problem-02-12 +#include +using namespace std; +void left_diagonal(int *a,int n,int m) +{ + int sum=0,j; + for(int i=0;i>n; + cout<<"enter columns "<>m; + int a[n][m]; + for(int i=0;i>a[i][j]; + } + } + for(int i=0;i +using namespace std; +int main() +{ + int n,m; + cout<<"enter rows "<>n; + cout<<"enter columns "<>m; + int a[n][m]; + for(int i=0;i>a[i][j]; + } + } + for(int i=0;i=i) + { + cout< +using namespace std; +int main() +{ + int n,m; + cout<<"enter rows "<>n; + cout<<"enter columns "<>m; + int a[n][m]; + for(int i=0;i>a[i][j]; + } + } + for(int i=0;i +using namespace std; +int main() +{ + int n,m; + cout<<"enter rows - "<>n; + cout<<"enter columns - "<>m; + int a[n][m],b[n][m],c[n][m]; + for(int i=0;i>a[i][j]; + + } + } + for(int i=0;i>b[i][j]; + + } + } + for(int i=0;i +using namespace std; +int main() +{ + int n,m; + cout<<"enter rows - "<>n; + cout<<"enter columns - "<>m; + int a[n][m],b[n][m],c[n][m]; + for(int i=0;i>a[i][j]; + } + } + for(int i=0;i>b[i][j]; + + } + } + for(int i=0;i +#include +using namespace std; +int main() +{ + string s1; + cout<<"enter your string"<>s1; + cout<<"length of the string is - "< +#include +using namespace std; +int main() +{ + string s1; + cout<<"enter string - "<>s1; + for(int i=s1.size()-1;i>=0;i--) + { + cout< +#include +using namespace std; + +int main() { + string str; + int count=0; + getline(cin,str); + for(int i=0;i +using namespace std; +int main() +{ + string s1,s2; + cout<<"enter first string "<>s1; + cout<<"enter sec string "<>s2; + s1=s1+s2; + cout<<"after concatination "< +using namespace std; +int main() +{ + string s1,s2; + cout<<"enter first string - "<>s1; + cout<<"enter second string - "<>s2; + if(s1==s2) + { + cout<<"strings are equal"< +using namespace std; +int main() +{ + string s1,s2; + cout<<"enter first string - "<=0;i--) + { + s2=s2+s1[i]; + } + cout< +using namespace std; +int main() +{ + string s1,s2; + cout<<"enter string - "<=0;i--) + { + s2=s2+s1[i]; + } + cout<<"reversed string - "< +using namespace std; +int main() +{ + int n,k; + cout<<"enter rows"<>n; + for(int i=1;i<=n;i++) + { + k=1; + for(int j=1;j<=i;j++) + { + cout< +using namespace std; +int main() +{ + int n,p,k; + cout<<"enter rows"<>n; + k=n; + for(int i=1;i<=n;i++) + { + p=k; + for(int j=1;j<=i;j++) + { + cout< +using namespace std; +int main() +{ + int n,k=1,p; + cout<<"enter rows"<>n; + for(int i=1;i<=n;i++) + { + k=1; + for(int j=1;j<=n;j++) + { + if(j<=(n+1)-i) + { + cout< +using namespace std; +int main() +{ + int n,k=1,p; + cout<<"enter rows"<>n; + for(int i=1;i<=n;i++) + { + p=k; + for(int j=1;j<=n;j++) + { + if(j<=(n+1)-i) + { + cout< +using namespace std; +int main() +{ + int n,k,p; + cout<<"enter n"<>n; + k=n; + for(int i=1;i<=n;i++) + { + p=k; + for(int j=1;j<=n;j++) + { + if(j<=(n+1)-i) + { + cout< +using namespace std; +int main() +{ + int n,k,p; + cout<<"enter n"<>n; + k=n; + for(int i=1;i<=n;i++) + { + k=n; + for(int j=1;j<=n;j++) + { + if(j<=(n+1)-i) + { + cout< +using namespace std; +int main() +{ + int n,k,p; + cout<<"enetr rows"<>n; + k=1; + for(int i=1;i<=n;i++) + { + p=k; + for(int j=1;j<=i;j++) + { + cout< +using namespace std; +int main() +{ + int n,k,p; + cout<<"enter rows"<>n; + for(int i=1;i<=n;i++) + { + k=n; + for(int j=1;j<=i;j++) + { + cout< +using namespace std; +int main() +{ + int n,k=1; + cout<<" enter rows"<>n; + for(int i=1;i<=n;i++) + { + for(int j=1;j<=i;j++) + { + cout< +using namespace std; +int main() +{ + int n,k,p; + cout<<"enter rows"<>n; + k=n; + for(int i=1;i<=n;i++) + { + for(int j=1;j<=i;j++) + { + cout< +using namespace std; +int main() +{ + int n,m; + cout<<"enter rows"<>n; + cout<<"enter columns"<>m; + for(int i=m;i>=1;i-=2) + { + for(int j=1;j<=i;j++) + { + cout< +using namespace std; +int main() +{ + int n,k=1,p; + cout<<"enter rows"<>n; + for(int i=1;i<=n;i++) + { k=1; + for(int j=1;j<=n;j++) + { + if(j<=(n+1)-i) + { + + if(i%2!=0) + { + + cout< +using namespace std; +int main() +{ + int n,k,p; + cout<<"enter rows"<>n; + k=n; + for(int i=1;i<=n;i++) + { + p=k; + for(int j=1;j<=n;j++) + { + if(j<=(n+1)-i) + { + cout< +using namespace std; +int main() +{ + int n,k,p; + cout<<"enter rows"<>n; + k=1; + for(int i=1;i<=n;i++) + { + for(int j=1;j<=n;j++) + { + if(j<=(n+1)-i) + { + cout< +using namespace std; +int main() +{ + int n,k,p; + cout<<"enter rows"<>n; + k=n; + for(int i=1;i<=n;i++) + { + p=k; + for(int j=1;j<=n;j++) + { + if(j<=i) + { + cout< +using namespace std; +int main() +{ + int n,k1,k2,p; + cout<<"enter rows"<>n; + for(int i=1;i<=n;i++) + { + for(int j=1;j<=i;j++) + { + if(i%2==0) + { + if(j%2==0) + { + cout<<"1"<<" "; + } + else{ + cout<<"0"<<" "; + } + } + else{ + if(j%2==0){ + cout<<"0"<<" "; + } + else{ + cout<<"1"<<" "; + } + } + } + cout< +using namespace std; +int main() +{ + int n,k1,k2,p; + cout<<"enter rows"<>n; + + for(int i=1;i<=n;i++) + { + k1=1; + k2=2; + for(int j=1;j<=i;j++) + { + if(i%2==0) + { + cout< +using namespace std; +int main() +{ + int n,k,p; + cout<<"enter rows"<>n; + k=1; + for(int i=1;i<=n;i++) + { + p=k; + for(int j=1;j<=n;j++) + { + if(j<=(n+1)-i) + { + cout< +using namespace std; +int main() +{ + for(int i=1;i<6;i++) + { + for(int j=1;j<=i;j++) + { + cout<<"*"<<" "; + } + cout< +using namespace std; +int main() +{ + int n; + cout<<"enter number of rows and columns"<>n; + for(int i=1;i<=n;i++) + { + for(int j=1;j<=(n-i);j++) + { + cout<<" "; + } + for(int k=1;k<=i;k++) + { + cout<<"*"; + } + cout< +using namespace std; +int main() +{ + int n,k; + cout<<"enter number of rows and columns"<>n; + int j=0; + for(int i=0;i +using namespace std; +int main() +{ + int n,k; + cout<<"enter number of rows and columns"<>n; + for(int i=0;i +using namespace std; +int main() +{ + int n,m; + cout<<"enter number of rows"<>n; + cout<<"enter number of columns"<>m; + for(int i=1;i<=n;i++) + { + for(int j=1;j<=m;j++) + { + if(j>=n-i+1 && j<=((n-1)+i)) + { + cout<<"*"; + } + else + { + cout<<" "; + } + } + cout< +using namespace std; +int main() +{ + int n,k; + cout<<"Enter number of rows"<>n; + for(int i=1;i<=n;i++) + { + k=n-i; + while(k) + { + cout<<" "; + k--; + } + for(int j=1;j<=i;j++) + { + cout<<"* "; + } + cout< +using namespace std; +int main() +{ + int n,m; + cout<<"enter no. of rows"<>n; + cout<<"enter np of columns"<>m; + for(int i=1;i<=n;i++) + { + for(int j=1;j<=m;j++) + { + if(j<=(n+1)-i || j>=(n-1)+i) + { + cout<<"*"; + } + else + { + cout<<" "; + } + } + cout< +using namespace std; +int main() +{ + int n,m,k; + cout<<"enter no.of rows"<>n; + cout<<"enter no.of columns"<>m; + for(int i=1;i<=n;i++) + { + k=1; + for(int j=1;j<=m;j++) + { + if(j>=(n+1)-i && j<=(n-1)+i) + { + cout< +using namespace std; +int main() +{ + int n,m,k; + cout<<"enter rows"<>n; + cout<<"enter columns"<>m; + for(int i=1;i<=n;i++) + { + k=65; + for(int j=1;j<=m;j++) + { + if(j<=(n+1)-i || j>=(n-1)+i) + { + cout<<(char)(k); + if(j<(n)) + { + k++; + } + else{ + k--; + } + } + else{ + cout<<" "; + if(j==n) + k--; + } + } + cout< +using namespace std; +int main() +{ + int n; + cout<<"enter no of rows"<>n; + int n1,n2; + n1=n/2; + n2=n-n1; + for(int i=1;i<=n1;i++) + { + for(int j=1;j<=n;j++) + { + if(j>=(n1+2)-i && j<=n1+i) + { + cout<<"*"; + } + else + { + cout<<" "; + } + } + cout<=i && j<=((n+1)-i)) + { + cout<<"*"; + } + else{ + cout<<" "; + } + } + cout< +using namespace std; +int main() +{ + int n; + cout<<"enter no of rows"<>n; + int n1,n2; + n1=n/2; + n2=n-n1; + for(int i=1;i<=n1;i++) + { + for(int j=1;j<=i;j++) + { + cout<<"*"; + } + cout< +using namespace std; +int main() +{ + int n,m; + cout<<"enter no of rows"; + cin>>n; + cout<<"enter no of columns"; + cin>>m; + for(int i=1;i<=n;i++) + { + for(int j=1;j<=m;j++) + { + if(j>=i && j<=(m+1)-i) + { + cout<<"*"; + } + else{ + cout<<" "; + } + } + cout< +using namespace std; +int main() +{ + int n,m,k; + cout<<"emter no of rows"<>n; + cout<<"enter no of columns"<>m; + for(int i=1;i<=n;i++) + { + k=65; + for(int j=1;j<=m;j++) + { + if(j>=(n+1)-i && j<=(n-1)+i) + { + cout<<(char)(k); + if(j<(m/2)+1) + { + k++; + } + else{k--; + } + } + else{ + cout<<" "; + } + } + cout< +using namespace std; +int main() +{ + int n,k; + cout<<"Enter number of rows"<>n; + for(int i=1;i<=n;i++) + { + k=n-i; + for(int j=1;j<=(n+1)-i;j++) + { + cout< +using namespace std; +int main() +{ + int n,k,n1,n2,l; + cout<<"Enter number of rows"<>n; + n1=n/2; + n2=n-n1; + for(int i=1;i<=n1;i++) + { + k=1; + for(int j=1;j<=n1-i+1;j++) + { + cout<<" "; + } + for(int j=1;j<=i;j++) + { + cout< +using namespace std; +int main() +{ + int n; + cout<<"Enter no. of rows and columns"<>n; + for(int i=1;i<=n;i++) + { + for(int j=1;j<=n;j++) + { + if(j==i || j==(n+1)-i) + { + if(j==i && j!=n/2+1) + { + cout<<"\\"; + } + else{ + cout<<"/"; + } + } + else + { + cout<<"*"; + } + } + cout< +using namespace std; +int main() +{ + int n,m ; + cout<<"enter no of rows "<>n; + cout<<"enter no of columns"<>m; + for(int i=1;i<=n;i++) + { + for(int j=1;j<=m;j++) + { + if(j>=i && j<=(m+1)-i) + { + cout<<"*"; + } + else{ + cout<<" "; + } + } + cout< +using namespace std; +int main() +{ + int n,m,k; + cout<<"enter no of rows"<>n; + cout<<"Enter no of columns"<>m; + for(int i=1;i<=n;i++) + { + k=65; + for(int j=1;j<=m;j++) + { + if(j>=(n+1)-i && j<=(n-1)+i) + { + cout<<(char)(k); + if(j<=m/2) + {k++; + } + else{ + k--; + } + } + else{ + cout<<" "; + } + } + cout< +using namespace std; +int main() +{ + int n,k,m,x; + cout<<"enter no of rows"<>n; + cout<<"Enter no of columns"<>m; + for(int i=1;i<=n;i++) + { + k=65; + x=1; + for(int j=1;j<=m;j++) + { + if(j>=(n+1)-i && j<=n+i) + { + if(j<=m/2) + { + cout<<(char)(k); + k++; + } + else{ + cout< +using namespace std; +int main() +{ + int n; + cout<<"enter no of rows"<>n; + for(int i=1;i<=n;i++) + { + for(int j=1;j<=n-i;j++) + { + cout<<" "; + } + for(int j=1;j<=5;j++) + { + cout<<"*"; + } + cout< +using namespace std; +int main() +{ + int n,m,x,k; + cout<<"enter no of rows"<>n; + cout<<"enter no of columns"<>m; + for(int i=1;i<=n;i++) + { + k=65; + x=1; + for(int j=1;j<=m;j++) + { + if(j>=(n+1)-i && j<=(n-1)+i) + { + if(j<=m/2+1) + { + cout< +using namespace std; +int main() +{ + int n; + cout<<"Enter rows"<>n; + for(int i=1;i<=n;i++) + { + for(int j=1;j<=i;j++) + { + if(j%2!=0) + { + cout<<"1"; + } + else{ + cout<<"0"; + } + } + cout< +using namespace std; +int main() +{ + int n=7; + for(int i=1;i<=n;i++) + { + for(int j=1;j<=n;j++) + { + if((i==1 || i==n || j==1 || j==n) || (i>=3&&i<=5&&j>=3&&j<=5) && (i==3||i==5||j==3||j==5)) + { + cout<<"*"; + } + else{ + cout<<" "; + } + } + cout< +using namespace std; +int main() +{ + int n,k=65,x,y; + cout<<"enter rows - "<>n; + y=k; + for(int i=1;i<=n;i++) + { + x=k; + + for(int j=1;j<=i;j++) + { + + cout<<(char)(x); + x--; + } + k++; + cout< +using namespace std; +int main() +{ + int n,m; + cout<<"enter rows"<>n; + cout<<"enter columns"<>m; + for(int i=1;i<=n;i++) + { + for(int j=1;j<=m;j++) + { + if(j>+(n+1)-i && j<=(n-1)+i) + { + cout<<"*"; + } + else{ + cout<" "; + } + } + cout< +using namespace std; +int main() +{ + int n,m,k=0,p; + + cout<<"enter rows"<>n; + cout<<"enter columns"<>m; + for(int i=1;i<=n;i++) + { + if(i%2!=0) + { + k=k+1; + } + else{ + k--; + k=k+i; + } + p=k; + for(int j=1;j<=m;j++) + { + if(j<=i*2-1) + { + if(j%2==0) + { + cout<<"*"; + } + else{ + if(i%2==0) + { + cout< +using namespace std; +int main() +{ + int n,k=64,p; + cout<<"enter rows"<>n; + for(int i=1;i<=n;i++) + { + k=k+i; + p=k; + for(int j=1;j<=n;j++) + { + if(j>=(n+1)-i) + { + cout<<(char)(p); + p--; + } + else{ + cout<<" "; + } + } + cout< +using namespace std; +int main() +{ + int n,count; + cout<<"enter n"<>n; + for(int i=1;i<=3*n;i++) + { + for(int j=1;j<=2*n-1;j++) + { + if(i<=n) + { + if(j>=2*n-i) + { + cout<<"*"; + } + else + { + cout<<" "; + } + } + else if(i<=2*n){ + count=0; + if(j==n) + { + cout<<"|"; + count=1; + } + if(j<=i-n-1) + { + count=1; + cout<<"*"; + } + if(j>=i) + { + cout<<"*"; + count=1; + } + + if(count==0) + { + cout<<" "; + } + } + else if(i<=3*n){ + if(j<=3*n+1-i) + { + cout<<"*"; + } + else{cout<<" "; + } + } + } + cout< +using namespace std; +int main() +{ + int n,m,x,k; + cout<<"enter rows"<>n; + cout<<"enter columns"<>m; + for(int i=1;i<=n;i++) + { + x=1; + k=65; + for(int j=1;j<=m;j++) + { + if(j>=(n+1)-i &&j<=(n-1)+i) + { + + if(i%2!=0 && j%2==0) + { + cout< +using namespace std; +int main() +{ + int n,m; + cout<<"enter rows"<>n; + cout<<"enter columns"<>m; + for(int i=1;i<=n;i++) + { + for(int j=1;j<=m;j++) + { + if(i==j || j==(n+1)-i) + { + cout<<"*"; + } + else{ + cout<<" "; + } + } + cout< +using namespace std; +int main() +{ + int n,m,k,p; + cout<<"enter rows"<>n; + cout<<"enter columns"<>m; + for(int i=1;i<=n;i++) + { + k=65; + for(int j=1;j<=m;j++) + { + if(j>=1 && j<=(n+1)-i || j>=(n-1)+i && j<=m) + { + cout<<(char)(k); + } + else{ + + cout<<" "; + } + k++; + } + cout< +using namespace std; +int main() +{ + int n,k=1,p; + cout<<"Enter rows"<>n; + for(int i=1;i<=n;i++) + { + p=k; + for(int j=1;j<=i;j++) + { + cout< +using namespace std; +int main() +{ + int n,k,p,l=0; + cout<<"enter rows"<>n; + for(int i=1;i<=n;i++) + { + k=0; + for(int j=1;j<=i;j++) + { + + cout<\"Open" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "1p0IGOlAZgeA", + "outputId": "2ed6bad5-2b7b-46fe-e843-5fac53e5bc08" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Cloning into 'Anomaly-Detection-in-CCTV-Surveillance-Videos'...\n", + "remote: Enumerating objects: 111, done.\u001b[K\n", + "remote: Total 111 (delta 0), reused 0 (delta 0), pack-reused 111\u001b[K\n", + "Receiving objects: 100% (111/111), 47.73 MiB | 10.37 MiB/s, done.\n", + "Resolving deltas: 100% (28/28), done.\n" + ] + } + ], + "source": [ + "!git clone https://github.com/ShrishtiHore/Anomaly-Detection-in-CCTV-Surveillance-Videos" + ] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": { + "id": "4j9ZdQCAmvC_" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "%cd Anomaly-Detection-in-CCTV-Surveillance-Videos/" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "fHz3mRPEZt0V", + "outputId": "8a2ecfe9-6124-4574-e2af-077ccb02bdfe" + }, + "execution_count": 2, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "/content/Anomaly-Detection-in-CCTV-Surveillance-Videos\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "%cd STAutoEncoder/" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "Ujx-7xGUZyAF", + "outputId": "7e39e557-b5d4-451c-94d5-ecb0a8f9609b" + }, + "execution_count": 3, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "/content/Anomaly-Detection-in-CCTV-Surveillance-Videos/STAutoEncoder\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "%cd /content/Anomaly-Detection-in-CCTV-Surveillance-Videos/STAutoEncoder\n", + "!unzip /content/Anomaly-Detection-in-CCTV-Surveillance-Videos/STAutoEncoder/training.zip\n", + "\n", + "\n", + "!pwd" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "xQChojMTZ2Nw", + "outputId": "73bff593-cf8c-4a39-fc7b-e2bfb002e955" + }, + "execution_count": 7, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "/content/Anomaly-Detection-in-CCTV-Surveillance-Videos/STAutoEncoder\n", + "Archive: /content/Anomaly-Detection-in-CCTV-Surveillance-Videos/STAutoEncoder/training.zip\n", + " inflating: training.npy \n", + "/content/Anomaly-Detection-in-CCTV-Surveillance-Videos/STAutoEncoder\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "!python test.py" + ], + "metadata": { + "id": "tj43jkcmZ6dh", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "8d275531-af0d-4bc1-8854-f1c8fc3a290e" + }, + "execution_count": 8, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "2022-05-05 10:07:50.196383: E tensorflow/stream_executor/cuda/cuda_driver.cc:271] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected\n", + "Bunch Normal\n", + "Bunch Normal\n", + "Bunch Normal\n", + "Bunch Normal\n", + "Bunch Normal\n", + "Bunch Normal\n", + "Bunch Normal\n", + "Bunch Normal\n", + "Bunch Normal\n", + "Bunch Normal\n", + "Bunch Normal\n", + "Bunch Normal\n", + "Bunch Normal\n", + "Bunch Normal\n", + "Bunch Normal\n", + "Bunch Normal\n", + "Bunch Normal\n", + "Bunch Normal\n", + "Bunch Normal\n", + "Bunch Normal\n", + "Bunch Normal\n", + "Bunch Normal\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "from google.colab import drive\n", + "drive.mount('/content/drive')" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "OWvvnCuztJnx", + "outputId": "1269fb57-8ea8-481b-f830-503338dd651b" + }, + "execution_count": 9, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Mounted at /content/drive\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "%cd /content/Anomaly-Detection-in-CCTV-Surveillance-Videos/STAutoEncoder" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "gnkQjW14mw9h", + "outputId": "256b2c5e-fd98-4dce-98f3-eeb14960f803" + }, + "execution_count": 10, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "/content/Anomaly-Detection-in-CCTV-Surveillance-Videos/STAutoEncoder\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "!python preprocess.py" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "S54vCM9ku2JB", + "outputId": "935846e6-a187-4496-a4a4-9f2cfbb4685b" + }, + "execution_count": 12, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Traceback (most recent call last):\n", + " File \"preprocess.py\", line 5, in \n", + " from scipy.misc import imresize\n", + "ImportError: cannot import name 'imresize' from 'scipy.misc' (/usr/local/lib/python3.7/dist-packages/scipy/misc/__init__.py)\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": { + "id": "xRL7zI-Gwrzh" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "!pip install scipy==1.1.0\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "R594UeKlwd_b", + "outputId": "9181157c-a91a-4558-8c8d-5b668ebbc5fd" + }, + "execution_count": 13, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Collecting scipy==1.1.0\n", + " Downloading scipy-1.1.0-cp37-cp37m-manylinux1_x86_64.whl (31.2 MB)\n", + "\u001b[K |████████████████████████████████| 31.2 MB 82.1 MB/s \n", + "\u001b[?25hRequirement already satisfied: numpy>=1.8.2 in /usr/local/lib/python3.7/dist-packages (from scipy==1.1.0) (1.21.6)\n", + "Installing collected packages: scipy\n", + " Attempting uninstall: scipy\n", + " Found existing installation: scipy 1.4.1\n", + " Uninstalling scipy-1.4.1:\n", + " Successfully uninstalled scipy-1.4.1\n", + "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n", + "pymc3 3.11.4 requires scipy>=1.2.0, but you have scipy 1.1.0 which is incompatible.\n", + "plotnine 0.6.0 requires scipy>=1.2.0, but you have scipy 1.1.0 which is incompatible.\n", + "jax 0.3.8 requires scipy>=1.2.1, but you have scipy 1.1.0 which is incompatible.\n", + "albumentations 0.1.12 requires imgaug<0.2.7,>=0.2.5, but you have imgaug 0.2.9 which is incompatible.\u001b[0m\n", + "Successfully installed scipy-1.1.0\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "!python preprocess.py \"/content/Anomaly-Detection-in-CCTV-Surveillance-Videos/Avenue/testing_videos\" 30" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "MtvjWViowtLq", + "outputId": "758d96a4-9a5f-4748-aa7e-f5a81350bde6" + }, + "execution_count": 32, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "['01.avi']\n", + "Found 1 training video\n", + "ffmpeg version 3.4.8-0ubuntu0.2 Copyright (c) 2000-2020 the FFmpeg developers\n", + " built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)\n", + " configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared\n", + " libavutil 55. 78.100 / 55. 78.100\n", + " libavcodec 57.107.100 / 57.107.100\n", + " libavformat 57. 83.100 / 57. 83.100\n", + " libavdevice 57. 10.100 / 57. 10.100\n", + " libavfilter 6.107.100 / 6.107.100\n", + " libavresample 3. 7. 0 / 3. 7. 0\n", + " libswscale 4. 8.100 / 4. 8.100\n", + " libswresample 2. 9.100 / 2. 9.100\n", + " libpostproc 54. 7.100 / 54. 7.100\n", + "Input #0, avi, from '/content/Anomaly-Detection-in-CCTV-Surveillance-Videos/Avenue/testing_videos/01.avi':\n", + " Metadata:\n", + " encoder : Lavf53.4.0\n", + " Duration: 00:00:57.56, start: 0.000000, bitrate: 2201 kb/s\n", + " Stream #0:0: Video: mpeg4 (Simple Profile) (XVID / 0x44495658), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 2197 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc\n", + "Stream mapping:\n", + " Stream #0:0 -> #0:0 (mpeg4 (native) -> mjpeg (native))\n", + "Press [q] to stop, [?] for help\n", + "\u001b[1;34m[swscaler @ 0x556f9d314000] \u001b[0m\u001b[0;33mdeprecated pixel format used, make sure you did set range correctly\n", + "\u001b[0m\u001b[1;36m[mjpeg @ 0x556f9cf87e00] \u001b[0m\u001b[0;33mbitrate tolerance 4000000 too small for bitrate 200000, overriding\n", + "\u001b[0mOutput #0, image2, to '/content/Anomaly-Detection-in-CCTV-Surveillance-Videos/Avenue/testing_videos/frames/%03d.jpg':\n", + " Metadata:\n", + " encoder : Lavf57.83.100\n", + " Stream #0:0: Video: mjpeg, yuvj420p(pc), 640x360 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 0.03 fps, 0.03 tbn, 0.03 tbc\n", + " Metadata:\n", + " encoder : Lavc57.107.100 mjpeg\n", + " Side data:\n", + " cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1\n", + "frame= 4 fps=2.3 q=1.6 Lsize=N/A time=00:02:00.00 bitrate=N/A dup=0 drop=1435 speed=67.8x \n", + "video:146kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown\n", + "preprocess.py:32: DeprecationWarning: `imresize` is deprecated!\n", + " `imresize` is deprecated in SciPy 1.0.0, and will be removed in 1.2.0.\n", + " Use ``skimage.transform.resize`` instead.\n", + " img=imresize(img,(227,227,3))\n", + "saving the numpy array\n", + "array save\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": { + "id": "pxtubI4z0ItI" + }, + "execution_count": null, + "outputs": [] + } + ] +} \ No newline at end of file