Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- void unos(char *s) {
- int i=0;
- char c;
- do {
- c=getchar();
- s[i]=c;
- i++;
- } while (c!='\n' && i<100);
- s[i-1]='\0';
- }
- int length (char *s) {
- int duzina=0;
- while (*(s++)!='\0') duzina++;
- return duzina;
- }
- void PretvoriBrojUString(char *s,int n) {
- int br=obrni(n);
- int i=0;
- while (br!=0) {
- s[i]=br%10+'0';
- br/=10;
- i++;
- }
- s[i]='\0';
- }
- int obrni (int n) {
- int nb=0;
- while (n!=0) {
- nb=nb*10+n%10;
- n/=10;
- }
- return nb;
- }
- void insert(char *string, char *word, int indeks)
- {
- int i;
- for(i = length(string) + length(word); i >= indeks + length(word); i--)
- {
- string[i] = string[i - length(word)];
- }
- for(i = 0; i < length(word); i++)
- {
- string[i + indeks] = word[i];
- }
- }
- void UbaciBrUString (char *s, int n) {
- char broj[50];
- PretvoriBrojUString(broj,n);
- int i=0, poc, kraj, duzina=length(s);
- for (i=0; i<duzina; i++) {
- while (s[i]!=' ') i++;
- poc=i;
- insert(s,broj,poc);
- i+=length(broj);
- }}
- int main () {
- char s[100];
- unos(s);
- UbaciBrUString(s,123);
- printf("%s", s);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement