lab8
This commit is contained in:
Binary file not shown.
Binary file not shown.
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.
Binary file not shown.
Binary file not shown.
@@ -1,61 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#define t1 8.75
|
||||
#define t2 9.33
|
||||
#define t3 10.00
|
||||
#define t4 11.20
|
||||
// #define t 10 //zp
|
||||
#define s 40 //sverh
|
||||
#define u 1.5 //sverh*
|
||||
#define n1 0.15 //tax1
|
||||
#define n2 0.2
|
||||
#define n3 0.25
|
||||
#define m1 300 //maxbeftax2
|
||||
#define m2 150
|
||||
|
||||
int main() {
|
||||
int h,sw,x,swt,exit,scan;
|
||||
float t,tax,a;
|
||||
exit = x = swt = scan = 1;
|
||||
while(exit){
|
||||
printf("hours: ");
|
||||
while(scanf("%d", &h)!=1){
|
||||
printf("input err\n");
|
||||
if(getchar() == EOF) return 0;
|
||||
while (getchar() != '\n') continue;
|
||||
printf("hours: ");
|
||||
}
|
||||
while (getchar() != '\n') continue;
|
||||
do{
|
||||
while (getchar() != '\n') continue;
|
||||
printf("Choose tarif:\n");
|
||||
printf("a) $%.2f/h\tb) $%.2f/h\n",t1,t2);
|
||||
printf("c) $%.2f/h\td) $%.2f/h\n",t3,t4);
|
||||
printf("q) exit\nInput: ");
|
||||
sw = getchar();
|
||||
if(getchar() == EOF){return 0;}
|
||||
while (getchar() != '\n') continue;
|
||||
switch(sw){
|
||||
case 'a': t = t1; swt = 0; break;
|
||||
case 'b': t = t2; swt = 0; break;
|
||||
case 'c': t = t3; swt = 0; break;
|
||||
case 'd': t = t4; swt = 0; break;
|
||||
case 'q': exit = 0; break;
|
||||
default: printf("input err\n");
|
||||
}
|
||||
}while(swt&&exit);
|
||||
|
||||
if(!swt && exit){
|
||||
if (h>s){tax = a = (s*t + ((h-s) * (t*u)));}
|
||||
else(tax = a = h*t);
|
||||
|
||||
if (tax>m1)
|
||||
{
|
||||
if(tax>m2){tax = (m1*n1) + (m2*n2) + ((tax-m1-m2)*n3);}
|
||||
else(tax = (m1*n1) + ((tax-m1)*n2));
|
||||
}
|
||||
else (tax*=n1);
|
||||
printf("Acc: %.3f\nTax: %.3f\nReceived: %.3f\n",a,tax,a-tax);
|
||||
}}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user