View difference between Paste ID: t5XWi5pF and UugGtWHL
SHOW: | | - or go back to the newest paste.
1
#include <stdio.h>
2-
#include <string.h>
2+
#include <ctype.h>
3-
#include <iostream.h>
3+
#define KONEC ".,:;?!\n\t"
4-
struct PRICE
4+
#define N 1024
5
6-
        char tovar[255];
6+
int Isupper(char *s)
7-
        char shop[255];
7+
8-
        int cena;
8+
	int i,count=0;
9-
};
9+
	for(i = 0 ; s[i] != '\0';i++)
10
		if(isupper(s[i]))
11
			count++;
12-
        const int n=2;
12+
	return count;
13-
        PRICE a[n],buf;
13+
}
14-
        char product[255];
14+
int Isdigit(char *s)
15-
        int i,j,flag=0;
15+
16-
        i=0;
16+
	int i,count=0;
17-
        while(i<2)
17+
	for(i = 0 ; s[i] != '\0';i++)
18-
        {
18+
		if(isdigit(s[i]))
19-
                cin.ignore();
19+
			count++;
20-
                printf("Vvedy nazvanie tovara\n");
20+
	return count;
21-
                gets(a[i].tovar);
21+
}
22-
                printf("Vvedy Nazvanie magazina\n");
22+
int Isalpha(char *s)
23-
                gets(a[i].shop);
23+
24-
                printf("Vvedy Ceny tovara\n");
24+
	int i,count=0;
25-
                scanf("%d",&a[i].cena);
25+
	for(i = 0 ; s[i] != '\0';i++)
26-
                i++;
26+
		if(isalpha(s[i]))
27-
        }
27+
			count++;
28-
        for (i=0;i<n-1;i++)
28+
	return count;
29-
                for (j=n-2;j>=i;j--)
29+
}
30-
                        if (strcmp(a[j].tovar,a[j+1].tovar)==1)
30+
void Del(char *s)
31-
                        {
31+
32-
                                buf = a[j];
32+
	int i,j;
33-
                                a[j]= a[j+1];
33+
	char buf;
34-
                                a[j+1] = buf;
34+
	for( i = 0 ; s[i] !='\0'; i++)
35-
                        }
35+
		if(s[i]=='A' || s[i]=='E' || s[i]=='I' || s[i]=='O' || s[i]=='U')
36-
        printf("vvedite tovar dl9 opisani9 \n");
36+
		{
37-
        scanf ("%s",product);
37+
			for(j=i;s[j+1] != '\0';j++)
38-
        printf("\tNAZVANIE MAGAZINA\tNAZVANIE TOVARA\t\tCENA\n");
38+
			{
39-
        for (i=0;i<n;i++)
39+
				buf=s[j];
40-
        {
40+
				s[j]=s[j+1];
41-
                printf("%25s",a[i].shop);
41+
				s[j+1]=buf;
42-
                printf("%20s",a[i].tovar);
42+
			}
43-
                printf("%15d\n",a[i].cena);
43+
			s[j]='\0';
44-
        }
44+
		}
45-
        printf("Svedenie o tovare\n");
45+
		puts(s);
46-
        for(i=0;i<n;i++)
46+
}
47-
                if (strcmp(a[i].tovar,product)==0)
47+
48-
                {
48+
49-
                        printf("%45s",a[i].shop);
49+
	char s[N];
50-
                        printf("%15d\n",a[i].cena);
50+
	char *word,*buf="\0";
51-
                        flag=1;
51+
	int i,j,flag[256]={0},k=0,max,end;
52-
                }
52+
	fgets(s,N,stdin);
53-
        if(flag==0)
53+
	for(i = 0; KONEC[i]; i++)
54-
                printf("Net takogo tovara !!\n");
54+
		flag[KONEC[i]]=1;
55-
        return 0;
55+
	for( i = 0 ; s[i] && flag[s[i]]; i++)
56
		;
57
	while(s[i])
58
	{
59
		word = &s[i];  //s + i;
60
		while( s[i] && !flag[s[i]])
61
			i++;	
62
		j = i;
63
		while( s[i] && flag[s[i]])
64
			i++;	
65
		s[j] = '\0';	
66
		end=strlen(word); //razmer stroki do \0 
67
		if(Isdigit(word)==end) // Slovo iz cifr
68
		{
69
			printf("\nSlovo TOKO IZ CIFR\n");
70
			puts(word);
71
		}
72
		
73
		
74
		if(Isalpha(word)==end) //slovo iz bukv
75
		{
76
			printf("\nSLovo TOKO IZ BUKV\n");
77
			puts(word);
78
		}
79
		
80
	
81
		
82
		if(Isupper(word)==end) // esli vse bukvi v stroke BIG
83
			if(end>strlen(buf))
84
			{
85
				max=end;
86
				buf=word;
87
			}	
88
	}
89
	printf("\nMax Stroka=\n");
90
	puts(buf);
91
	printf("\nvizov DEL\n");
92
	Del(buf);
93
	printf("\nOTVET\n");
94
	puts(buf);
95
	return 0;
96
}