Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Array non repeated alphabets
//gcc 4.9.3 #include <stdio.h> #include <stdlib.h> void input(int *p,int n) { int i; srand(getpid()); for(i=0;i<n;i++) { p[i]=rand()%26+65; if(ifRepeated(p,i)) { i--; } } } void print(int *p,int n) { int i; printf("**the array***\n"); for(i=0;i<n;i++) printf("p[%d]=%c\n",i,p[i]); } void vowles(int *p,int n) { int i,ch; printf("***VOWLES***\n"); for(i=0;i<n;i++) { switch(p[i]) { case 'A':printf("p[%d]=%c\n",i,p[i]); break; case 'E':printf("p[%d]=%c\n",i,p[i]); break; case 'I':printf("p[%d]=%c\n",i,p[i]); break; case 'O':printf("p[%d]=%c\n",i,p[i]); break; case 'U':printf("p[%d]=%c\n",i,p[i]); break; } } } int ifRepeated(int *p,int i) { int j=i-1; while(j>=0) { if(p[j]==p[i]) return 1; j--; } return 0; } main() { int a[20]; int n; n=sizeof(a)/sizeof(a[0]); input(a,n); print(a,n); vowles(a,n); }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Project 4 v1.1
Vowel Assignment
otro avance de pregunta 2
150116_PrimoFactorial
Multiple if statement v0.8
In Class 1.23.17 Bit operations
Simple interest
bit wise operation
11
square pyramid
Please log in to post a comment.