Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <stddef.h>
- #include <math.h>
- #include <string.h>
- int sum_greater(const int a, const int b, const int c){
- if(a >= b && a >= c){
- if(b >= c){
- return a + b;
- }
- else{
- return a + c;
- }
- }
- if(b >= a && b >= c){
- if(a >= c){
- return b + a;
- }
- else{
- return b + c;
- }
- }
- if(c >= b && c >= a){
- if(b >= a){
- return c + b;
- }
- else{
- return a + c;
- }
- }
- }
- int min_2d(const int size, int array[][size]){
- int sum = array[0][0];
- for(int i = 0; i < size; i++){
- for(int j = 0; j < size; j++){
- if(array[i][j] < sum){
- sum = array[i][j];
- }
- }
- }
- return sum;
- }
- char last_letter(const char string[]){
- char str;
- for(int i = 0; i < strlen(string); i++){
- if((string[i] >= 'a' && string[i] <= 'z') || (string[i] >= 'A' && string[i] <= 'Z')){
- str = string[i];
- }
- }
- return str;
- }
- int longest_row(const int rows, const int cols, char array[rows]){
- /*int arr[rows];
- int max = 0;
- printf("%d", rows);
- for(int i = 0; i < rows; i++){
- arr[i] = strlen(array[i]);
- }
- for(int i = 0; i < rows; i++){
- if(arr[i] > max){
- max = arr[i];
- }
- }
- for(int i = 0; i < rows; i++){
- if(arr[i] == max){
- return i;
- }
- }*/
- int result = 0;
- int longest = 0;
- for(int y = 0; y < rows; y++){
- int len = strlen(array[y]);
- if(result < len){
- result = len;
- longest = y;
- }
- }
- return longest;
- }
- int main(){
- //printf("%d\n", sum_greater(2, 8, 8));
- //int array[2][2] = { {1, 2}, {0, -3} };
- //printf("%d\n", min_2d(2, array));
- //printf("%c %c\n", last_letter("Once upon a time...."), last_letter("$a_b_c_d_1_2_3_4$"));
- char array[3][31] = {"Hello","Hello, how are you?","I hope today is a lucky day..."};
- printf("%d\n", longest_row(3,31,array));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement