Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- Online C Compiler.
- Code, Compile, Run and Debug C program online.
- Write your code in this editor and press "Run" button to compile and execute it.
- *******************************************************************************/
- #include <stdio.h>
- #include <time.h>
- int main( ) // program kopiowania z stdin na stdout
- {
- srand(time(NULL));
- int c,d,i,j;
- d=10;
- char tab[d];
- i=0;
- // zad4
- // for(i=0; i<d-1 && (c = getchar()) != EOF && c!='\n'; i++)
- // tab[i]=c;
- // if(c=='\n'){
- // tab[i] = c;
- // i++;
- // }
- //zad 5
- for(i=0; i<d-1; i++)
- tab[i]= 'a' + rand()%('z'-'a'+1);
- // koniec zad 5
- tab[i]='\0';
- printf("Tablica z wpisanych liczb: \n");
- i=0;
- while(tab[i]!='\0'){
- printf("\t znak: jako znak %c, jako liczba %d\n", tab[i++], tab[i]);
- }
- return 0;
- }
- // PLIK 2
- #include <stdio.h>
- int main() // program zliczania cyfr i innych znaków we wczytywanym napisie
- {
- int i, nwhite=0, nother=0; // zmienne do zliczania
- int ndigit[10]={0}; // w tym tablica inicjowana zerami
- int c; // c definiowane jako int bo EOF niekoniecznie jest znakiem
- while( (c = getchar()) != EOF) { // wczytywanie kolejnych znaków aż do EOF
- if(c>=48 && c<=57){
- ndigit[c-'0']++;
- printf("%c, %d, %d\n", c, c-'0', ndigit[c-'0']);
- }
- else if(c==10 || c==32 || c==9){
- nwhite++;
- }
- else{
- nother++;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement