can some1 try 2 correct these codes...

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

char letters[]={'a','b','c','d'};
int unique(int i, int n[]);
void shuffle(){
int i, a, n[100];
char temp;
i=strlen(letters[]);
for(a=0;a<i;a++){
x:;
n[a]=random(i-1);
if(a!=0 && unique( a+1, n[] )==0)
goto x;
}
printf("Letters after shuffling: ");
for(a=0;a<i;i++)
printf("%c ", letters[i]);
getch();
}

main(){
int i;
clrscr();
printf("Letters before shuffling: ");
for(i=0;i<strlen(letters[]);i++)
printf("%c ", letters[i]);
printf("\n\n");
getch();
shuffle();

}

int unique(int i, int n[]){
int a, b;
for(a=0; a<i; a++)
for(b=a+1;b<i;i++)
if(n[a]==n[b])
return 0;
return 1;
}

/* all it does is to shuflle the letters but it has errors please help me*/
karl, tuleg lagay mo kung san tungkol yan wag ganyan.. haha

aayusin ko yan teka..

this is my own fucking codes. :D

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{
  char poss[] = "qwerty";

  int i,r,l = strlen(poss);
  srand(time(NULL));

  for (i=0; i<l; i++)
  {
   r = rand()%(l-i);
   putchar(poss[r]);
   memmove(poss+r,poss+r+1,l-r);
  }

  puts("");

}

what errors does it have?

let me rephrase, what kind of errors are you getting?
Last edited on
Topic archived. No new replies allowed.