Padi
Padi
#include <stdio.h>
#include <string.h>
strcpy(op, ip);
if (mode) {
strcat(op, "0");} }
if (op[i] == '1') {
if (op[i+j] == poly[j]) {
op[i+j] = '0';
} else {
if (op[i] == '1') {
return 1;}
int main() {
scanf("%s", ip);
scanf("%s", recv);
return 0;}
____________________________________________________________________________
Bit stuff
#include<stdio.h>
#include<string.h>
int main(){
char data[50],stuff[100],dstuff[50];
int i,j,cnt,len;
printf("Enter data\n");
scanf("%s",data);
len=strlen(data);
cnt=0;
j=0;
for(i=0;i<len;i++)
if (data[i]=='1')
cnt++;
else
cnt=0;
stuff[j]=data[i];
j++;
}
stuff[j]='\0';
// destuffing
printf("Destuffed data:%s",stuff);
return 0;
_______________________________________________________________
Distance vector
#include <stdio.h>
#include <stdlib.h>
int main() {
int i, j, k, n, g[10][10];
scanf("%d", &n);
// Input graph
scanf("%d", &g[i][j]);
if (g[i][j] != INF) {
d[i][j] = 1;
}} }
via[i][j] = i;
}}
if (d[i][j] == 1) {
via[i][j] = k;}}}}
// Output results
return 0;}
}___________________________________________________________________
Link state
#include<stdio.h>
int main(){
int count,src_router,i,j,k,w,v,min;
int cost_matrix[100][100],dist[100],last[100];
int flag[100];
scanf("%d",&count);
printf("\n Enter the cost matrix values:");
for(i=0;i<count;i++){
for(j=0;j<count;j++){
printf("\n%d->%d:",i,j);
scanf("%d",&cost_matrix[i][j]);
if(cost_matrix[i][j]<0)cost_matrix[i][j]=1000;}}
scanf("%d",&src_router);
for(v=0;v<count;v++){
flag[v]=0;
last[v]=src_router;
dist[v]=cost_matrix[src_router][v];}
flag[src_router]=1;
for(i=0;i<count;i++){
min=1000;
for(w=0;w<count;w++){
if(!flag[w])
if(dist[w]<min){
v=w;
min=dist[w];}}
flag[v]=1;
for(w=0;w<count;w++){
if(!flag[w])
if(min+cost_matrix[v][w]<dist[w]){
dist[w]=min+cost_matrix[v][w];
last[w]=v;}}}
for(i=0;i<count;i++){
printf("\n%d==>%d:Path taken:%d",src_router,i,i);
w=i;
while(w!=src_router){
printf("\n<--%d",last[w]);w=last[w];}
____________________________________________________________
#include <stdlib.h>
#include <string.h>
str[i] -= num;}}
str[i] += num;}}
int main() {
int choice;
char str[100];
int num;
printf("Choose an option:\n");
printf("4. Exit\n");
do {
scanf("%d", &choice);
switch (choice) {
case 1:
scanf("%s", str);
scanf("%d", &num);
break;
case 2:
encrypt(str, num);
break;
case 3:
decrypt(str, num);
break;
case 4:
printf("Exiting...\n");
break;
default:
printf("Invalid choice.\n");
break; }
return 0;}
__________________________________________________