每日打卡
#include <stdio.h>
void PrintN(int N);
int main()
{
int N;
scanf_s("%d", &N);
PrintN(N);
return 0;
}
void PrintN(int N)
{
for (int i = 0; i < N; i++)
{
printf("%d", i + 1);
if (i != N - 1)
{
printf("\n");
}
}
}
#include <stdio.h>
#define MAXN 10
#include<math.h>
double f(int n, double a[], double x);
int main()
{
int n, i;
double a[MAXN], x;
scanf_s("%d %lf", &n, &x);
for (i = 0; i <= n; i++)
scanf_s("%lf", &a[i]);
printf("%.1f\n", f(n, a, x));
return 0;
}
double f(int n, double a[], double x)
{
double sum = 0;
for (int i = 0; i <=n; i++)
{
sum += a[i] * pow(x, i);
}
return sum;
}
#include <stdio.h>
#define MAXN 10
int Sum(int List[], int N);
int main()
{
int List[MAXN], N, i;
scanf_s("%d", &N);
for (i = 0; i < N; i++)
scanf_s("%d", &List[i]);
printf("%d\n", Sum(List, N));
return 0;
}
int Sum(int List[], int N)
{
int sum = 0;
for (int i = 0; i < N; i++)
{
sum += List[i];
}
return sum;
}
#include <stdio.h>
#define MAXN 10
typedef float ElementType;
ElementType Average(ElementType S[], int N);
int main()
{
ElementType S[MAXN];
int N, i;
scanf_s("%d", &N);
for (i = 0; i < N; i++)
scanf_s("%f", &S[i]);
printf("%.2f\n", Average(S, N));
return 0;
}
ElementType Average(ElementType S[], int N)
{
float sum = 0;
float average = 0.0;
for (int i = 0; i < N; i++)
{
sum += S[i];
}
average = (float)sum / N;
return average;
//}
#include <stdio.h>
#define MAXN 10
typedef float ElementType;
ElementType Max(ElementType S[], int N);
int main()
{
ElementType S[MAXN];
int N, i;
scanf_s("%d", &N);
for (i = 0; i < N; i++)
scanf_s("%f", &S[i]);
printf("%.2f\n", Max(S, N));
return 0;
}
ElementType Max(ElementType S[], int N)
{
for (int i = 0; i < N - 1; i++)
{
int count = 0;
for (int j = 0; j < N - 1 - i; j++)
{
if (S[j] < S[j + 1])
{
float temp;
temp = S[j];
S[j] = S[j + 1];
S[j + 1] = temp;
count++;
}
} if (count == 0)
{
return S[0];
break;
}
}
return S[0];
}
#include <stdio.h>
#include <math.h>
#include<iostream>
using namespace std;
//void IsTheNumber(const int N);
int main()
{
int n1, n2, /*i,*/ cnt;
cin >> n1;
/* scanf("%d %d", &n1, &n2);*/
cnt = 0;
//for (i = n1; i <= n2; i++) {
//IsTheNumber(n1);
// cnt++;
//}
//printf("cnt = %d\n", cnt);
// return 0;
//}
//void IsTheNumber(const int N)
//{
int x = n1; int i = 1; int t = 0; int s = 0;
while (x / 10 != 0)
{
x /= 10;
i++;
}
int y = n1;
int* a = new int[i];
for (int j = 0; j < i; j++)
{
a[j] = y % 10;
y/= 10;
}
for (int j = 0; j < i; j++)
{
cout << a[j]<< endl;;
}
for (int k = 0; k < i; k++)
{
int count = 1;
for (int l = k+1; l < i; l++)
{
if (a[k] == a[l])
{
count++;
}
}
if (t < count)
{
t = count;
}
}
if (t >= 2)
{
for (int i = 0; i <n1; i++)
{
if (i * i == n1)
{
s++;
}
}
}
}
#include <stdio.h>
#include <math.h>
int IsTheNumber(const int N);
int main()
{
int n1, n2, i, cnt;
scanf_s("%d %d", &n1, &n2);
cnt = 0;
for (i = n1; i <= n2; i++) {
if (IsTheNumber(i)==true)
cnt++;
}
printf("cnt = %d\n", cnt);
return 0;
}
int IsTheNumber(const int N)
{
int x = N; int i = 1; int t = 0; int s = 0;
while (x / 10 != 0)
{
x /= 10;
i++;
}
int y = N;
int* a = new int[i];
for (int j = 0; j < i; j++)
{
a[j] = y % 10;
y/= 10;
}
for (int k = 0; k < i; k++)
{
int count = 1;
for (int l = k+1; l < i; l++)
{
if (a[k] == a[l])
{
count++;
}
}
if (t < count)
{
t = count;
}
}
if (t >= 2)
{
for (int i = 0; i <N; i++)
{
if (i * i == N)
{
s++;
break;
}
}
}
if ( s == 1)
{
return true;
}
}
本文来自博客园,作者:赵千万,转载请注明原文链接:https://www.cnblogs.com/zhaoqianwan/p/17350761.html
千万千万赵千万