Untitled

 avatar
unknown
plain_text
2 years ago
1.8 kB
4
Indexable
#include <stdio.h>
long sum(long a, long b){
    return a+b;
}

int main(){
    long a, b;
    scanf("%ld %ld", &a, &b);
    printf("%ld", sum(a, b));
    assertEqual(a+b, sum(a,b));
    return 0;
}





#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int count(long long int a){
    int count_one =0;
    while(a!=0){
        count_one+=a%2;
        a=a/2;
    }
    return count_one;
}

int main(){
    long long int a;
    scanf("%lld",&a);
    int s = count(a);
    printf("%d",s);
    return 0;
}





#include <stdio.h>
#include <stdlib.h>

float pow_(int a, int b){
    float res = 1;
    if (b >= 0){
        for (int i = 0; i<b; i++){
            res *= a;
        }
    }
    else {
        for (int i = 0; i<abs(b); i++){
            res /= a;
        }
    }
    return res;
}

int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%f", pow_(a, b));
    //assertEqual(pow_(2, 3), 8);
    return 0;
}







#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int count(char* str) {
    int count_probel=0;
    for (int i = 0; i < strlen(str); i++) {
        if (str[i]==' '){
        count_probel++;
        }
    }
    char* tmp;
    tmp = strtok(str," ");
    
    char** words_arr;
    words_arr= malloc(sizeof (char*)*count_probel);
    
    int count=0;
    while(tmp!=NULL){
        words_arr[count++]=tmp;
        tmp= strtok(NULL," \n");
    }
    
    int max_count=0;
    for (int i = 0; i < count; i++) {
        int ccount=0;
        for (int j = 0; j < count; j++) {
            if(strcmp(words_arr[i],words_arr[j])==0){
                ccount++;
            }
        }
        if(ccount>=max_count){
            max_count=ccount;
        }
    }
    return max_count;
}

int main(){
    char str[200];
    fgets(str,200,stdin);
    int c = count(str);
    printf("%d",c);
    return 0;
}
Editor is loading...