Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // gcc -o patrones patrones.c -std=c99
- #include <stdio.h>
- #include <string.h>
- #define PATRONES 41
- void patronA (char * s){
- void* address= s+10;
- while ( (void*)s++ <address){if (*s!='*') {*s='*'; break;}}
- };
- void patronB (char * s){
- void* address= s;
- s+=11;
- while ( (void*)s-- >address) {if (*s!=' ') {*s=' '; break;}}
- };
- void patronC (char * s){
- void* address= s+10;
- do{if (*s!=' ') {*s=' '; break;}}while ( (void*)s++ <address);
- };
- void patronD (char * s){
- void* address= s;
- s+=11;
- do{if (*s!='*') {*s='*'; break;}} while ( (void*)s-- >address) ;
- };
- int main (){
- char cadena []={" "};
- for (int i=0;i<PATRONES;i++)
- {
- if (i<10) {patronA (cadena);}
- if (i>=11 && i<20) {patronB (cadena);}
- if (i==21) {memset (cadena,'*',sizeof (cadena));}//Llena de * para patron C
- if (i>=21 && i<32) {patronC (cadena);}
- if (i>=32) {patronD(cadena);}
- printf ("%s \n",cadena);
- }
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement