Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char Testo[MAX],Cifrato[MAX],c;
- int i=0,K,j=0,delta,resto;
- printf("inserisca il numero di K:");
- scanf("%d",&K);
- if(K>26)
- {
- resto=K%26;
- K=K-(26*resto);
- }
- delta=K-26;
- printf("inserisca il testo:");
- while(getchar()!='\n');
- while((c=getchar())!='\n')
- {
- Testo[i]=c;
- i++;
- }
- Testo[i]='\0';
- while(Testo[j]!='\0')
- {
- if((Testo[j]>='a' && Testo[j]<='z') || (Testo[j]>='A' && Testo[j]<='Z'))
- {
- if((Testo[j]>=('z'-K) && Testo[j]<='z') || (Testo[j]>=('Z'-K) && Testo[j]<='Z'))
- {
- Cifrato[j]=Testo[j]+delta;
- }
- else
- Cifrato[j]=Testo[j]+K;
- }
- j++;
- }
- Cifrato[j+1]='\0';
- printf("%s\n",Cifrato);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement