Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int obrni(int broj)
- {
- int novi=0;
- while(broj!=0)
- {
- novi*=10;
- novi+=broj%10;
- broj/=10;
- }
- return novi;
- }
- char *Zamijeni (char *string) {
- char *p=string;
- char novi[100];
- char *s=novi;
- int suma=0;
- while (*p!='\0'){
- if (*p>='0' && *p<='9') {
- while (*p>='0' && *p<='9') {
- suma+=*p-'0';
- p++;
- }
- obrni(suma);
- while (suma!=0) {
- *s++=(char)(suma%10+'0');
- suma/=10;
- }
- }
- else *s++=*p++;
- }
- *s='\0';
- strcpy(string, novi);
- return string;
- }
- int main () {
- char s[]="Na Antartiku ima 254 pingvina i 13 polarnih medvjeda.";
- char nova[100];
- char *poc=nova;
- poc=Zamijeni(s);
- while (*poc!='\0') {
- printf("%c", *poc);
- poc++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement