Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <ctype.h>
- int count_zeros();
- int count_vowels();
- int max();
- int index();
- int largest();
- void swap();
- int main(){
- ////////////////////////////////////////////COUNT ZEROS
- int array[4][4] = { {1, 0, -10, 0},
- {0,-3, 0, 8},
- {0,0,69,420},
- {5,0,1,0}
- };
- printf("ZEROS = %d\n",count_zeros(4,array));
- /////////////////////////////////////////////COUNT VOWELS
- char strings[3][50] = {"hello WORLD!", "aHOJú", "Ahoj"};
- printf("VOWELS = %d\n", count_vowels(3,50,strings));
- ////////////////////////////////////////////MAX
- int array2[4][4] = { {1,5,9,250},
- {-5,-95,124,0},
- {7,8,666,0},
- {2254,-665,14,3},
- };
- printf("MAX NUMBER = %d\n", max(4,array2));
- ///////////////////////////////////////LONGEST STRING
- char sarray[3][50] = {
- {"Hello sdsds u"},
- {"jeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"},
- {"keeeee"}};
- printf("INDEX = %d\n",index(3,50,sarray));
- ///////////////////////////////////////LARGEST
- int array3[3][3] = {{1,0,1},{0,-3,5},{150,1,4}};
- printf("%d\n", largest(3, array3));
- ///////////////////////////////////////SWAP CASE
- char strings2[2][50] = {{"Ahoj ako sa Mas FeRo"},
- {"jeNbvEfRtoLp"}};
- swap(2,50,strings2);
- for(int o = 0; o<2; o++){
- for(int k=0; k<50; k++){
- printf("%c",strings2[o][k]);
- }
- printf("\n");
- }
- return 0;
- }
- void swap(const int rows, const int cols, char strings[][cols]){
- for(int o=0; o<rows; o++){
- for(int k=0; k<cols; k++){
- if(isupper(strings[o][k])){
- strings[o][k] = tolower(strings[o][k]);
- }else
- strings[o][k] = toupper(strings[o][k]);
- }
- }
- }
- int largest(const int size, int array[][size]){
- if(array == NULL)
- return -1;
- int number=0, pomnumber=0,index=0;
- for(int o=0; o<size; o++){
- number+=array[0][o];
- }
- for(int k=0; k<size; k++){
- for(int n=0; n<size; n++){
- pomnumber+=array[k][n];
- if(pomnumber > number){
- number = pomnumber;
- index = k;
- }
- }
- }
- return index;
- }
- int index(const int rows, const int cols, char strings[rows][cols]){
- if(strings == NULL)
- return -1;
- int index=0,len0=strlen(strings[0]);
- for(int o=0; o<rows; o++){
- int len = strlen(strings[o]);
- if(len0 < len){
- len0 = len;
- index=o;
- }
- }
- return index;
- }
- int max(const int size, int array[][size]){
- if(array == NULL)
- return -1;
- int number = 0;
- for(int o=0; o<size; o++){
- for(int k=0; k<size; k++){
- if(array[o][k] > number)
- number = array[o][k];
- }
- }
- return number;
- }
- int count_vowels(const int rows, const int cols, char strings[][cols]){
- if(strings == NULL)
- return -1;
- int count =0;
- char lt;
- for(int o=0; o<rows; o++){
- for(int k=0; k<cols; k++){
- lt = tolower(strings[o][k]);
- if(lt == 'a' || lt == 'e' || lt == 'i' || lt == 'o' || lt == 'u')
- count++;
- }
- }
- return count;
- }
- int count_zeros(const int size, int array[][size]){
- if(array == NULL)
- return -1;
- int count = 0;
- for(int o=0; o<size; o++){
- for(int k=0; k<size; k++){
- if(array[o][k] == 0){
- count++;
- }
- }
- }
- return count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement