
12.06.2008, 02:16
|
|
Banned
Регистрация: 22.12.2007
Сообщений: 660
С нами:
9677126
Репутация:
1158
|
|
Код:
#include <stdio.h>
main()
{
int c, nl, t, space, n, i, l;
char array[100];
nl = c = t = space = n = 0;
for (i = 0; i < 100; ++i) {
array[i] = 0;
}
i = 0;
for(i=0;(array[i]=(char )getchar())!=EOF;i++) {
if (array[i] == '\n') {
printf("\nSymbol: ");
for (l = 0; l < i; ++l) {
printf("%d ", array[l]);
}
printf("\nTab: %d\nSpace: %d\nNumber: %d\n", t, space, n);
break;
}
else if (c == '\t') {
++t;
}
else if (c == ' ') {
++space;
}
else if (c >= '0' && c <= '9') {
++n;
}
}
}
ya perepisal kod nemonogo podrugomu, On vse ravno vidaet takoi resultat:
[root@procedure /tmp/programming]# cc cpstring.c
cpstring.c:62:4: warning: no newline at end of file
[root@procedure /tmp/programming]# /tmp/programming/a.out
sadfg
Symbol: 115 97 100 102 103
Tab: 0
Space: 0
Number: 0
[root@procedure /tmp/programming]#
|
|
|