You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
1.8 KiB
76 lines
1.8 KiB
8 months ago
|
#include <stdio.h>
|
||
|
/* подсчет цифр, символов-разделителей и прочих символов */
|
||
|
int main()
|
||
|
{
|
||
|
int c, i, j, nwhite, nother;
|
||
|
int ndigit[10];
|
||
|
nwhite = nother = 0;
|
||
|
for (i = 0; i < 10; ++i)
|
||
|
ndigit[i] = 0;
|
||
|
while ((c = getchar()) != EOF)
|
||
|
{
|
||
|
if (c >= '0' && c <= '9')
|
||
|
++ndigit[c - '0'];
|
||
|
else if (c == ' ' || c == '\n' || c == '\t')
|
||
|
++nwhite;
|
||
|
else
|
||
|
++nother;
|
||
|
}
|
||
|
printf("цифры =");
|
||
|
for (i = 0; i < 10; ++i)
|
||
|
printf(" %d", ndigit[i]);
|
||
|
printf(", символы-разделители = %d, прочие = %d\n", nwhite, nother);
|
||
|
|
||
|
for(i = 0; i<100; ++i){
|
||
|
for(j = 0; j<10; ++j){
|
||
|
--ndigit[j];
|
||
|
if (ndigit[j] >= 0)
|
||
|
printf("|");
|
||
|
else if (ndigit[j] == -1)
|
||
|
printf("-");
|
||
|
else
|
||
|
printf(" ");
|
||
|
}
|
||
|
printf("\n");
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
#include <stdio.h>
|
||
|
#include <ctype.h>
|
||
|
|
||
|
#define MAXLEN 30
|
||
|
|
||
|
void resh(char s1[], char s2[]);
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
char in[MAXLEN] = "-A-Z1-9\0";
|
||
|
char out[MAXLEN];
|
||
|
|
||
|
printf("s1 = %s\n",in);
|
||
|
resh(in, out);
|
||
|
printf("s2 = %s\n",out);
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
void resh(char s1[], char s2[])
|
||
|
{
|
||
|
int i, j;
|
||
|
for( i = 0, j = 0; s1[i] != 0; i++){
|
||
|
if (s1[i] = '-'){
|
||
|
if (isdigit(s1[i-1])&&isdigit(s1[i+1])&&s1[i-1] < s1[i+1]||
|
||
|
islower(s1[i-1])&&islower(s1[i+1])&&s1[i-1] < s1[i+1]||
|
||
|
isupper(s1[i-1])&&isupper(s1[i+1])&&s1[i-1] < s1[i+1]){
|
||
|
for(char t = (char)(s1[i-1]+1); t<s1[i+1]; t++){
|
||
|
s2[j++] = t;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
s2[j++] = s1[i];
|
||
|
}
|
||
|
else
|
||
|
s2[j++] = s1[i];
|
||
|
}
|
||
|
s2[j] ='\0';
|
||
|
|
||
|
}
|