Codeee
Codeee
Codeee
#include <stdio.h>
#include <string.h>
int main()
{
int demso = 0, demchu = 0;
char str[101];
scanf("%s",str);
for(int i = 0; i < strlen(str); i++)
{
if((str[i] >= 48 && str[i] <= 57))
{
demso++;
}
if((str[i] >= 65 && str[i] <= 90) || (str[i] >= 97 && str[i] <= 122))
{
demchu++;
}
}
if(demso == demchu)
{
printf("0");
}
else if(demso < demchu)
{
printf("1");
}
else
{
printf("2");
}
return 0;
}
Exercise 2:
#include <stdio.h>
#include <math.h>
int main()
{
int p, n = 0, x = 0;
scanf("%d", &p);
while (p > 0)
{
n += (p % 10) * pow(2, x);
++x;
p /= 10;
}
printf("%d",n);
return 0;
}
Exercise 3:
#include <stdio.h>
int main()
{
int a, b, max = 0;
scanf("%d %d", &a, &b);
if (a > b)
{
max = a;
}
else
max = b;
printf("%d", max);
return 0;
}
Exercise 4:
#include <stdio.h>
int main()
{
int n = 0, s[40], t[40], a = 0;
char c;
for (int i = 0; i < 40; i++)
{
scanf("%d", &s[i]);
n++;
c = getchar();
if (c == '\n')
break;
}
for (int i = 0; i < n; i++)
{
if (s[i] > 20 && s[i] < 30)
{
t[a] = s[i];
a++;
}
}
int temp = 0;
for(int i = 0; i < a-1; i++)
{
for(int j = i; j < a; j++)
{
if(t[i] > t[j])
{
temp = t[i];
t[i] = t[j];
t[j] = temp;
}
}
}
for(int i = 0; i < a; i++)
{
printf("%d ",t[i]);
}
return 0;
}
Exercise 5:
#include <stdio.h>
int main()
{
int N, p = 1, point = 1, dong = 0;
scanf("%d", &N);
while (dong < N)
{
for (int i = 0; i < point; i++)
{
printf("%d ", p);
p++;
}
point++;
dong++;
printf("\n");
}
return 0;
}