lab8
This commit is contained in:
Binary file not shown.
@@ -1,16 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(){
|
||||
int a,n1,sum1,n2,sum2;
|
||||
n1 = sum1 = n2 = sum2 = 0;
|
||||
printf("num: ");
|
||||
a = 1;
|
||||
while(scanf("%d", &a) && a != 0){
|
||||
if (a % 2 == 0){n1++; sum1 += a;}
|
||||
if (a % 2 != 0){n2++; sum2 += a;}
|
||||
printf("num: ");
|
||||
}
|
||||
printf("eve nums: %d \t eve summ: %d \t mean: %d\n",n1,sum1,(sum1/n1));
|
||||
printf("odd nums: %d \t odd summ: %d \t mean: %d",n2,sum2,(sum2/n2));
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
@@ -1,13 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int a,b,c;
|
||||
a = b = c = 0;
|
||||
printf("count ef:\n");
|
||||
while((a = getchar()) != '#'){
|
||||
if(a == 'i' && b == 'e'){c++;}
|
||||
b = a;
|
||||
}
|
||||
printf("count: %d",c);
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
@@ -1,25 +0,0 @@
|
||||
#include <stdio.h>
|
||||
int pr(long long n);
|
||||
|
||||
int main() {
|
||||
long long int x,i;
|
||||
|
||||
if(!(scanf("%lld",&x)))return 1;
|
||||
|
||||
for(i = x; i > 1; --i)
|
||||
if(pr(i))
|
||||
printf("%lld\t",i);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pr(long long n) {
|
||||
if (n < 2) return 0;
|
||||
if (n == 2 || n == 3) return 1;
|
||||
if (n % 2 == 0 || n % 3 == 0) return 0;
|
||||
|
||||
for (long long i = 5; i * i <= n; i += 6) {
|
||||
if (n % i == 0 || n % (i + 2) == 0)
|
||||
return 0;}
|
||||
return 1;
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user