parent
c81f1fa9cb
commit
7c82ff70b2
@ -0,0 +1,21 @@ |
||||
#include <stdio.h> |
||||
#include <math.h> |
||||
|
||||
int main() { |
||||
int number = 0; |
||||
scanf("%d", &number); |
||||
|
||||
int length = 0; |
||||
while ((number % (int)pow(10, length)) != number) { |
||||
length ++; |
||||
} |
||||
|
||||
int digital = 0, maxDigital = 0; |
||||
for (int i = 0; i < length; ++i) { |
||||
digital = number % 10; |
||||
maxDigital = digital > maxDigital ? digital : maxDigital; |
||||
number /= 10; |
||||
} |
||||
|
||||
printf("%d", maxDigital); |
||||
} |
@ -0,0 +1,21 @@ |
||||
#include <stdio.h> |
||||
|
||||
int main() { |
||||
int n = 0; |
||||
scanf("%d", &n); |
||||
|
||||
double numerator = 2.0, //和分母
|
||||
denominator = 1.0; //分子
|
||||
|
||||
double oldNumerator = 0.0; |
||||
|
||||
double result = 0.0; |
||||
for (int i = 0; i < n; ++i) { |
||||
result += numerator / denominator; |
||||
oldNumerator = numerator; |
||||
numerator += denominator; |
||||
denominator = oldNumerator; |
||||
} |
||||
|
||||
printf("%.6f", result); |
||||
} |
@ -0,0 +1,45 @@ |
||||
#include <stdio.h> |
||||
#include <cstring> |
||||
|
||||
struct Student { |
||||
char name[16]; |
||||
int score; |
||||
}; |
||||
|
||||
void sort(Student *students, int count); |
||||
void copy(Student *target, Student *source); |
||||
|
||||
int main() { |
||||
int studentNumber = 0; |
||||
scanf("%d", &studentNumber); |
||||
|
||||
Student students[studentNumber]; |
||||
for (int i = 0; i < studentNumber; ++i) { |
||||
scanf("%s %d", students[i].name, &students[i].score); |
||||
} |
||||
|
||||
sort(students, studentNumber); |
||||
|
||||
for (Student student : students) { |
||||
printf("%s %d\n", student.name, student.score); |
||||
} |
||||
} |
||||
|
||||
void sort(Student *students, int count) { |
||||
Student temp{}; |
||||
|
||||
for (int i = 0; i < count - 1; ++i) { |
||||
for (int j = 0; j < count - 1 - i; ++j) { |
||||
if (students[j].score < students[j + 1].score) { |
||||
copy(&temp, &students[j + 1]); |
||||
copy(&students[j + 1], &students[j]); |
||||
copy(&students[j], &temp); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
void copy(Student *target, Student *source) { |
||||
strcpy(target->name, source->name); |
||||
target->score = source->score; |
||||
} |
Loading…
Reference in new issue