-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a9e107c
commit f1e3ec0
Showing
156 changed files
with
1,122,639 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# cs50 | ||
these are all my cs50 psets | ||
|
||
[pset3,pset5,pset8 are not complete and others might not work as they were made from cs502018 course] |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include<cs50.h> | ||
#include<stdio.h> | ||
|
||
int main(void) | ||
{ | ||
float n; | ||
int c; | ||
int y; | ||
while(1) | ||
{ | ||
n= get_float("change owed :"); | ||
if(n>0) | ||
{ | ||
break; | ||
} | ||
else | ||
{ | ||
continue; | ||
} | ||
} | ||
c=n/0.25; | ||
n=n-(c*0.25); | ||
y=n/0.10; | ||
c=c+y; | ||
n=n-(y*0.10); | ||
y=n/0.05; | ||
c=c+y; | ||
n=n-(y*0.05); | ||
y=n/0.01; | ||
c=c+y; | ||
printf("the amount of coins : %d",c); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include<stdio.h> | ||
#include<cs50.h> | ||
#include<math.h> | ||
|
||
int main(void) | ||
{ | ||
long int n; | ||
int sum=0; | ||
int sum1=0; | ||
int sum2=0; | ||
long int R=0,y=0; | ||
while(1) | ||
{ | ||
n= get_long_long("enter your card number :"); | ||
if(n>0) | ||
{ | ||
break; | ||
} | ||
else | ||
{ | ||
continue; | ||
} | ||
} | ||
for(int i=1;i<=13;i+=2) | ||
{ | ||
R=n/pow(10,i); | ||
sum1+=(2*(R%10)); | ||
} | ||
for(int J=0;J<=15;J+=2) | ||
{ | ||
y=n/pow(10,J); | ||
sum2+=(y%10); | ||
} | ||
sum=sum1+sum2; | ||
if (sum%10==0) | ||
{ | ||
printf("VISA\n"); | ||
} | ||
else printf("INVALID\n"); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include<stdio.h> | ||
|
||
int main(void) | ||
{ | ||
printf("hello,world \n"); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include<stdio.h> | ||
int main(void) | ||
{ | ||
int n; | ||
scanf("how long do you want the pyramid : %d",&n); | ||
int x=n; | ||
int y; | ||
for(int i=0;i<n;i++) | ||
{ | ||
for(int k=0;k<x;k++) | ||
{ | ||
printf(" "); | ||
} | ||
y=n-x; | ||
x--; | ||
for(int j=0;j<y;j++) | ||
{ | ||
printf("__"); | ||
} | ||
printf(" "); | ||
for(int l=0;l<y;l++) | ||
{ | ||
printf("__"); | ||
} | ||
printf("\n"); | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include<stdio.h> | ||
#include<cs50.h> | ||
#include<string.h> | ||
void cipher(int a); | ||
int main(int k,char *a[]) | ||
{ | ||
if (k>2&&k<2) | ||
{ | ||
printf("error , enter a correct value pf key."); | ||
return 1; | ||
} | ||
else | ||
{ | ||
int i= atoi(a[1]); | ||
if (i<=26&&i>=1) | ||
{ | ||
cipher(i); | ||
} | ||
else | ||
{ | ||
int n=0; | ||
n=i/26; | ||
i=i-(n*26); | ||
cipher(i); | ||
} | ||
} | ||
} | ||
void cipher(a) | ||
{ | ||
string s=get_string("enter a sentence to cipher :"); | ||
int n=strlen(s); | ||
for(int j=0;j<n;j++) | ||
{ | ||
s[j]+=a; | ||
} | ||
printf("cipher text :%s",s); | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#include<stdio.h> | ||
#include<cs50.h> | ||
#include<string.h> | ||
#define _XOPEN_SOURCE | ||
#include <unistd.h> | ||
void decipher(string hp,string s); | ||
string crypt(string key,string salt); | ||
int main(int k,string a[]) | ||
{ | ||
string t= a[1]; | ||
char salt[2]; | ||
if (k>2&&k<2) | ||
{ | ||
printf("error , enter a correct value of key."); | ||
return 1; | ||
} | ||
else | ||
{ | ||
salt[0]=t[0]; | ||
salt[1]=t[1]; | ||
decipher(t,salt); | ||
} | ||
} | ||
void decipher(string hp,string s) | ||
{ | ||
char pass[5]; | ||
string hashed; | ||
string alphabet="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | ||
//for five characters | ||
for(int i=0;i<52;i++) | ||
{ | ||
pass[0]=alphabet[i]; | ||
hashed=crypt(pass,s); | ||
if(strcmp(hashed,hp)==0) | ||
{ | ||
goto print; | ||
} | ||
for(int j=0;j<52;j++) | ||
{ | ||
pass[1]=alphabet[i]; | ||
hashed=crypt(pass,s); | ||
if(strcmp(hashed,hp)==0) | ||
{ | ||
goto print; | ||
} | ||
for(int k=0;k<52;k++) | ||
{ | ||
pass[2]=alphabet[i]; | ||
hashed=crypt(pass,s); | ||
if(strcmp(hashed,hp)==0) | ||
{ | ||
goto print; | ||
} | ||
for(int l=0;l<52;l++) | ||
{ | ||
pass[3]=alphabet[i]; | ||
hashed=crypt(pass,s); | ||
if(strcmp(hashed,hp)==0) | ||
{ | ||
goto print; | ||
} | ||
for(int m=0;m<52;m++) | ||
{ | ||
pass[4]=alphabet[i]; | ||
hashed=crypt(pass,s); | ||
if(strcmp(hashed,hp)==0) | ||
{ | ||
goto print; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
print: printf("deciphered text : %s",pass); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include<stdio.h> | ||
#include<cs50.h> | ||
#include<string.h> | ||
#include<ctype.h> | ||
void cipher(int h[],int o); | ||
int main(int k,string a[]) | ||
{ | ||
string t=a[1]; | ||
int n=strlen(t); | ||
int f[n]; | ||
if (k>2&&k<2&&(isalpha(a[1])==0)) | ||
{ | ||
printf("error , enter a correct value key."); | ||
return 1; | ||
} | ||
else | ||
{ | ||
for(int j=0;j<n;j++) | ||
{ | ||
f[j]=t[j]; | ||
if(f[j]>=97) | ||
{ | ||
f[j]-=97; | ||
} | ||
else if(f[j]>=65) | ||
{ | ||
f[j]-=65; | ||
} | ||
} | ||
cipher(f,n); | ||
} | ||
return 0; | ||
} | ||
void cipher(int h[],int o) | ||
{ | ||
string s=get_string("plaintext :"); | ||
int m=strlen(s); | ||
int b=0; | ||
for (int j=0;j<m;j++) | ||
{ | ||
if(isalpha(s[j])) | ||
{ | ||
if(b>=o) | ||
{ | ||
b=0; | ||
} | ||
s[j]+=h[b]; | ||
if(!isalpha(s[j])) | ||
{ | ||
if(s[j]>=123) | ||
{ | ||
s[j]-=97; | ||
s[j]%=26; | ||
s[j]+=97; | ||
} | ||
else if(s[j]>=92) | ||
{ | ||
s[j]-=65; | ||
s[j]%=26; | ||
s[j]+=65; | ||
} | ||
} | ||
b++; | ||
} | ||
} | ||
printf("ciphertext :%s",s); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
CC ?= clang | ||
CFLAGS ?= -fsanitize=integer -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wshadow | ||
LDLIBS ?= -lcs50 -lm | ||
|
||
.PHONY: all | ||
all: notes synthesize | ||
|
||
notes: helpers.c helpers.h notes.c wav.c wav.h | ||
$(CC) $(CFLAGS) -o notes helpers.c notes.c wav.c $(LDLIBS) | ||
|
||
synthesize: synthesize.c wav.c wav.h helpers.c helpers.h | ||
$(CC) $(CFLAGS) -o synthesize helpers.c synthesize.c wav.c $(LDLIBS) | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f notes synthesize *.wav |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
D4@1/8 | ||
D4@1/8 | ||
E4@1/4 | ||
D4@1/4 | ||
G4@1/4 | ||
F#4@1/2 | ||
D4@1/8 | ||
D4@1/8 | ||
E4@1/4 | ||
D4@1/4 | ||
A4@1/4 | ||
G4@1/2 | ||
D4@1/8 | ||
D4@1/8 | ||
D4@1/4 | ||
B4@1/4 | ||
G4@1/4 | ||
F#4@1/4 | ||
E4@1/4 | ||
C4@1/8 | ||
C4@1/8 | ||
B4@1/4 | ||
G4@1/4 | ||
A4@1/4 | ||
G4@1/2 |
Oops, something went wrong.