Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int obrni (int n) {
- int nb=0;
- while (n!=0) {
- nb=nb*10+n%10;
- n/=10;
- }
- return nb;
- }
- int duzina(char *s) {
- int duz=0,i=0;
- while (s[i++]!='\0') duz++;
- return duz;
- }
- int JeLiBroj (char c)
- {
- if (c>='0' && c<='9') return 1;
- return 0;
- }
- void cut(char *string, int indeks, int len)
- {
- int i;
- for(i = indeks; i <= duzina(string) - len; i++)
- {
- string[i] = string[i + len];
- }
- }
- void Izbaci (char *s, int n) {
- int nb=0,i,poc, kraj;
- int len=duzina(s);
- if (n>0) {
- for (i=0; i<len; i++) {
- if (JeLiBroj(s[i])) {
- poc=i;
- nb=nb*10+(s[i]-'0');
- i++;
- while (JeLiBroj(s[i])) {
- nb=nb*10+(s[i]-'0');
- i++;
- }
- kraj=i;
- if (nb>n) {
- cut(s, poc, kraj-poc);
- i-=(kraj-poc);
- }
- nb=0;
- }}}
- else {
- n*=-1;
- for (i=0; i<len; i++) {
- if(s[i]=='-' && JeLiBroj(s[i+1])) {
- i++;
- poc=i;
- nb=nb*10+(s[i]-'0');
- i++;
- while (JeLiBroj(s[i])) {
- nb=nb*10+s[i]-'0';
- i++; }
- kraj=i;
- if (nb<n) {
- cut (s,poc-1,kraj-poc+1);
- i-=(kraj-poc+1);
- }
- nb=0;
- }
- }}
- }
- int main () {
- char rec[]="U gradovima -68 i 910 -22 temperatura je bila -1 stepena";
- Izbaci(rec,-23);
- printf("\nNova recenica: %s", rec);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement