Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string.h>
- #include <stdio.h>
- char szWord[99] = "SONY12",
- sz_2 [99];
- int _strlen(char *psz);
- void _strcpy(char*, char*);
- /////////////////////////////////
- int main() //
- {
- int n = _strlen(szWord);
- printf("n = %d\n", n);
- _strcpy(sz_2, szWord);
- printf("sz_2 = %s\n", sz_2);
- }
- //////////////////////////////////////////////////
- void _strcpy(char *psz1, char *psz2) // Скопировался ли терминальный ноль?
- {
- int i = 0;
- do
- {
- psz1[i] = psz2[i];
- }
- while( psz2[++i] != 0);
- }
- ///////////////////////////////////
- int _strlen(char *psz) //
- {
- int i = 0;
- while( szWord[++i] != 0);
- return i;
- }
- /*
- ///////////////////////////////////
- int _strlen(char *psz) //
- {
- int i = 0;
- for(; szWord[i] != 0; i++)
- {
- // printf("%2d\n", szWord[i]);
- } // printf("%2d\n", szWord[i]);
- return i;
- }
- */
- // if(szWord[i] == 0) { printf("OGO!\n"); break; }
- /*
- #include <stdlib.h>
- #include <time.h>
- #include <stdio.h>
- char szWord[99] = "SONY_Pictures";
- /////////////////////////////////
- int main() //
- {
- for(int i = 0; szWord[i] == 0; i++)
- {
- printf("%c\n", szWord[i]);
- // if(szWord[i] == 0) { printf("OGO!\n"); break; }
- }
- }
- */
- /*
- #include <stdlib.h>
- #include <time.h>
- #include <stdio.h>
- void monitor(int *p);
- /////////////////////////////////
- int main() //
- {
- srand(time(0));
- int array[20],
- nx, // min
- ng; // max
- for(int i = 0; i < 20; i++)
- {
- array[i] = rand()%200;
- }
- monitor(array);
- ng = array[0];
- nx = array[0];
- int nIndex_Max = 0,
- nIndex_min = 0;
- for(int i = 0; i < sizeof(array)/4; i++ )
- {
- if(array[i] > ng)
- {
- ng = array[i];
- nIndex_Max = i;
- }
- if(array[i] < nx)
- {
- nx = array[i];
- nIndex_min = i;
- }
- }
- printf("Max element array: %d, his index = %d\n", ng, nIndex_Max);
- printf("min element array: %d, his index = %d\n", nx, nIndex_min);
- return 0;
- }
- /////////////////////////////////////////////////////
- void monitor(int *p) //
- {
- for(int i = 0; i < 20; i++)
- {
- printf("%d\n", p[i]);
- }
- }
- */
- //1FF89C74B82CA48BA44CB6A6D570FD9C3513DA72FD004FD27806A83479FC9A09BB8CE85A988F
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement