Since finishing up more slowly, if you like java or python people want the code, please private letter I leave a message or comment area.
This is the last semester freshman code written relatively immature, if you want to see which analyze a topic or will not do, can private letter I, or comment will do, if painted zzulioj think the code below useful, like a point look at the pictures.
These are the most basic questions, the questions will not do in this oj, finishing reason is because you want to help people in need, while recording at his own immaturity.
If there is a missing topic, private letter or comment. I will be back.
ZZULI- brush road Subjects
zzulioj_1000-1010
zzulioj_1011-1050
table of Contents
To find the distance between two points
Seeking area of the triangle
Determine the number of daffodils
Analyzing the first few points in quadrant
A certain period of how many days
Cubic sum given sum of squares
Cylinder surface area
#include <stdio.h>
#define PI 3.14159
int main (void )
{
double r,h;
scanf("%lf%lf", &r , &h);
printf("%.2f\n", 2*PI*r*r + 2*PI*r*h);
return 0;
}
Absolute value
#include <stdio.h>
#include<math.h>
int main()
{
double a, b;
scanf("%lf",&a);
b = fabs(a);
printf("%.2f\n",b);
return 0;
}
To find the distance between two points
#include <stdio.h>
#include<math.h>
int main()
{
double a, b, c, d;
scanf("%lf%lf%lf%lf", &a, &b, &c, &d);
printf("%.2f\n",sqrt((a - c)*(a - c)+(b - d)*(b - d)));
return 0;
}
Seeking area of the triangle
#include <stdio.h>
#include<math.h>
int main()
{
double a, b, c, r;
scanf("%lf%lf%lf", &a, &b, &c);
r = (a + b + c)/2;
printf("%.2f\n",sqrt(r*(r - a)*(r - b)*(r - c)));
return 0;
}
Calculation interval
#include <stdio.h>
#include<math.h>
int main(void)
{
int a, b, c, d, e, f;
scanf("%d:%d:%d\n", &a, &b, &c);
scanf("%d:%d:%d", &d, &e, &f);
printf("%d",(d - a)*3600 + (e - b)*60+(f-c)*1);
return 0;
}
Bank interest rates
#include <stdio.h>
#include <math.h>
int main()
{
double a, b, z, c=1.0225;
scanf("%lf%lf", &a, &b);
z=pow(c,a);
z=z*b;
printf("%f\n", z);
return 0;
}
True or integer digits
#include<stdio.h>
int main ()
{
int n, i = 0;
scanf("%d", &n);
while (n > 0)
{
n = n / 10;
i++;
}
printf("%d", i);
return 0;
}
Odd Even
#include <stdio.h>
#include <math.h>
int main()
{
int n;
scanf("%d",&n);
if(n%2==0)
{
printf("even\n");
}
else
{
printf("odd");
}
return 0;
}
Park Tickets
#include <stdio.h>
int main()
{
int a;
scanf("%d",&a);
if(a>=30)
{
printf("%d\n", a*48);
}
else
{
printf("%d\n", a*50);
}
return 0;
}
Sort two integer
#include <stdio.h>
int main()
{
int a, b;
scanf("%d%d",&a, &b);
if(a<b)
{
printf("%d %d\n", a, b);
}
else
{
printf("%d %d\n", b, a);
}
return 0;
}
A maximum of three integers
#include <stdio.h>
int main()
{
int a, b, c, max;
scanf("%d%d%d",&a, &b, &c);
max =(a > b) ? a : b;
max =(max > c) ? max : c;
printf("%d", max);
return 0;
}
Three integer sorting
#include "stdio.h"
int main()
{
int x,y,z,t;
scanf("%d%d%d", &x, &y, &z);
if (x < y)
{
t = x;
x = y;
y = t;
}
if(x < z)
{
t = x;
x = z;
z = t;
}
if (y < z)
{
t = y;
y = z;
z = t;
}
printf("%d %d %d", x, y, z);
return 0;
}
Case conversion
#include <stdio.h>
int main()
{
char ch;
ch = getchar();
if(ch>='a' && ch<='z')
{
ch-=32;
printf("%c\n", ch);
}
else
{
printf("%c\n", ch);
}
return 0;
}
Letter number calculation
#include <stdio.h>
int main()
{
char ch;
ch = getchar();
if(ch>='A' && ch<='Z')
{
ch+=32;
}
ch = ch - 96;
printf("%d\n", ch);
return 0;
}
The maximum character
#include "stdio.h"
int main()
{
char x,y,z,t;
scanf("%c %c %c", &x, &y, &z);
t = x;
if (t < y)
{
t = y;
}
if (t < z)
{
t = z;
}
printf("%c", t);
return 0;
}
Character type judgment
#include <stdio.h>
int main()
{
char ch;
ch = getchar();
if(ch >= 'a' && ch <= 'z')
{
printf("lower");
}
else
{
if(ch >= 'A' && ch <= 'Z')
{
printf("upper");
}
else
{
if(ch >= '0' && ch <= '9')
{
printf("digit");
}
else
{
printf("other");
}
}
}
return 0;
}
Determine the number of daffodils
#include "stdio.h"
int main()
{
int n, a, b, c, m;
scanf("%d", &n);
m = n;
a = n % 10;
n = n /10;
b = n % 10;
n = n /10;
c = n % 10;
if ((a*a*a + b*b*b +c*c*c ) == m)
printf("yes");
else
printf("no");
return 0;
}
I love leap year!
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
if ((n % 400 == 0 ) || ((n % 4 == 0)&&( n % 100 != 0)))
printf("Yes");
else
printf("No");
return 0;
}
Triangle decision
#include <stdio.h>
int main()
{
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
if(((a + b) > c) && ((b + c) > a) && ((a + c) > b))
printf("Yes");
else
printf("No");
return 0;
}
Judge right triangle
#include <stdio.h>
int main()
{
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
if(((a*a + b*b) == c*c) || ((b*b+ c*c) == a*a))
printf("yes");
else
{
if( (a*a + c*c) == b*b)
printf("yes");
else
printf("no");
}
return 0;
}
Analyzing the first few points in quadrant
#include <stdio.h>
int main()
{
int a, b;
scanf("%d%d", &a, &b);
if((a > 0) && (b > 0))
printf("1");
else if((a>0) && (b < 0))
printf("4");
else if((a < 0) && (b > 0))
printf("2");
else if((a < 0) && (b < 0))
printf("3");
return 0;
}
Staff salaries
#include <stdio.h>
int main()
{
int a, b;
scanf("%d", &a);
if(a <= 10000)
{
b = 1500 + 0.05*a;
printf("%.2f", 1.00 * b);
}
else
{
if(a > 10000 && a <= 50000)
{
b = 1500 + 10000 * 0.05 + (a - 10000) * 0.03;
printf("%.2f", 1.00 * b);
}
else
{
b = 1500 + 10000 * 0.05 + 40000 * 0.03 + (a - 50000) * 0.02;
printf("%.2f", 1.00 * b);
}
}
return 0;
}
Five-tier system performance
#include <stdio.h>
int main()
{
int n;
char m;
scanf("%d", &n);
if ( n >= 90)
m = 'A';
else if (( n>=80)&& (n <= 89))
m= 'B';
else if((n >= 70)&&(n <= 79))
m = 'C';
else if((n <= 69)&&( n >= 60))
m = 'D';
else
m ='E';
printf("%c", m);
return 0;
}
Summer Promotion
#include <stdio.h>
int main(void)
{
int a;
double b;
scanf("%d", &a);
a = 1.0 * a;
if(a < 500)
{
b = a;
printf("%.2f", b);
}
if(a >= 500 && a < 1000)
{
b = a * 0.95;
printf("%.2f", b);
}
if(a >= 1000 && a < 3000)
{
b = a * 0.9;
printf("%.2f", b);
}
if(a >= 3000 && a< 5000)
{
b = a * 0.85;
printf("%.2f", b);
}
if(a >= 5000)
{
b = a * 0.8;
printf("%.2f", b);
}
return 0;
}
Piecewise function evaluation
#include <stdio.h>
#include<math.h>
int main ()
{
int a, b, c;
scanf("%d", &a);
if(a < -2)
{
b = 7 - 2 * a;
printf("%d", b);
}
else
{
if(a >= 3)
{
b = 3 * a + 4;
printf("%d", b);
}
else
{
c = 3 * a + 2;
c = fabs(c);
b = 5 - c;
printf("%d", b);
}
}
return 0;
}
A certain period of how many days
#include<stdio.h>
int main ()
{
int year, month, days;
scanf("%d %d", &year, &month);
switch(month)
{
case 4:
case 6:
case 9:
case 11: days = 30; break;
case 2:
if((year%400 == 0)||(year%4 == 0 && year%100 != 0))
days = 29;
else
days = 28;
break;
default: days = 31;
}
printf("%d\n",days);
return 0;
}
The maximum absolute value
#include<stdio.h>
#include<math.h>
int main()
{
int a, b, c, max;
scanf("%d%d%d", &a, &b, &c);
max = a;
if( abs(max) < abs(b))
max = b;
if( abs(c) > abs(max))
max = c;
printf("%d", max);
return 0;
}
summing the number n
#include<stdio.h>
int main ()
{
int n, b, sum, i;
scanf("%d", &n);
sum = 0;
for(i = 1;i <= n; i++)
{
scanf("%d", &b);
sum = sum + b;
}
printf("%d", sum);
return 0;
}
Number Summation 2
#include<stdio.h>
#include<math.h>
int main ()
{
int n, i;
double sum, b, c;
scanf("%d", &n);
for(i =0;i <= (n - 1) ; i++)
{
b = 1.0 * i;
c = pow(-1,b);
sum = sum + c * 1 /(2 * b +1);
}
printf("%.2f", sum);
return 0;
}
Number Summation 3
#include<stdio.h>
#include<math.h>
int main ()
{
int n, i, q;
double sum, b, c;
scanf("%d", &n);
q = 1;
for(i =0;i <= (n - 1) ; i++)
{
b = 1.0 * i;
c = pow(-1,b);
sum = sum + c * q /(2 * b +1);
q = q + 1;
}
printf("%.3f", sum);
return 0;
}
Failure rates
#include<stdio.h>
int main ()
{
int n, i, q, b;
double a;
scanf("%d", &n);
b = 0;
for(i = 1; i <= n; i++)
{
scanf("%d", &q);
if (q < 60)
b++;
}
a = 1.0 * b / (n * 1.0);
printf("%.2f", a);
return 0;
}
Numerical statistics
v#include<stdio.h>
int main ()
{
int a, b, c, n, i, q;
scanf("%d", &n);
a = 0;
b = 0;
c = 0;
for(i = 1; i <= n; i++)
{
scanf("%d", &q);
if (q < 0)
{
a++;
}
else
{
if(q > 0)
{
c++;
}
else
{
b++;
}
}
}
printf("%d %d %d", a, b, c);
return 0;
}
Odd product
#include<stdio.h>
int main ()
{
int n, i;
int a, b=1;
scanf("%d", &n);
for (i = 1; i <= n;i++)
{
scanf("%d", &a);
if (a % 2 != 0)
{
a = b * a;
b = a;
}
}
printf("%d", b);
return 0;
}
Table of logarithms
#include<stdio.h>
#include<math.h>
int main ()
{
int a, b;
double y;
scanf("%d%d", &a, &b);
for( a = a; a <= b; )
{
y = log(a);
printf("%4d%8.4f\n", a, y);
a = a + 1;
}
return 0;
}
Factorial table
#include<stdio.h>
int main ()
{
double n, i, a;
double b, y=1;
scanf("%lf", &n);
for (i = 1; i <= n; i++)
{
for(a=1; a <= i;a++)
{
b = a ;
}
y = b * y;
printf("%-4.0f%-20.0f\n", i, y);
}
return 0;
}
Cubic sum given sum of squares
#include<stdio.h>
int main ()
{
int m, n, a;
int b, y=0, x=0;
scanf("%d%d",&m, &n);
for(m = m; m <= n;m++)
{
if(m % 2 == 0)
{
b = m * m;
y = b + y;
}
else
{
a = m * m *m;
x = x + a;
}
}
printf("%d %d", y, x);
return 0;
}
Factorial and accumulation
#include<stdio.h>
int main ()
{
int n, i;
int x=1, y = 0;
scanf("%d",&n);
for(i=1; i <= n;i++)
{
x = x * i;
y = y + x;
}
printf("%d", y);
return 0;
}