Вот задания все. Прикрепляю файлами. Но на всякий случай, еще код сюда:
1)
#include "stdio.h"
#include "stdlib.h"
using namespace std;
int main(){
char a[256];
int amount = 0;
printf("Enter text: "); scanf("%s", &a);
for(int i = 0 ; i < sizeof(a)/sizeof(*a); i += 1){
if(a[i] == 'a') amount ++;
}
printf("result: %d\n", amount);
system("pause");
return 0;
}
2)
#include "stdio.h"
#include "stdlib.h"
using namespace std;
struct SchoolChild{
char gender;
char last_name[20];
char first_name[20];
int weight;
int height;
};
int main(){
int N; //amount of pupils
int amount_girls = 0, amount_boys = 0;
int average_height_girls = 0;
int average_weight_boys = 0;
int max_height_boys = 0;
printf("Enter amount of pupils: "); scanf("%d",&N); fflush(stdin);
SchoolChild A[N];
for(int i = 0; i < N; i++){
printf("Informantion about %d\n", i+1);
printf("Gender: "); scanf("%c",&A[i].gender); _flushall();
printf("Last_name: "); scanf("%s",&A[i].last_name); _flushall();
printf("First_name: "); scanf("%s",&A[i].first_name); fflush(stdin);
printf("Weight(kg)): "); scanf("%d",&A[i].weight); fflush(stdin);
printf("Height(cm)): "); scanf("%d",&A[i].height); fflush(stdin);
printf("__________________________________________________\n");
}
fflush(stdin);
for(int i = 0; i < N; i++){
if(A[i].gender == 'М' or A[i].gender == 'M'){
amount_boys +=1;
if(A[i].height > max_height_boys){
max_height_boys = A[i].height;
}
average_weight_boys += A[i].weight;
}else if(A[i].gender == 'F' or A[i].gender == 'Ж'){
amount_girls +=1;
average_height_girls += A[i].height;
}
}
if(amount_boys > 0)
average_weight_boys = average_weight_boys / amount_boys;
if(amount_girls > 0)
average_height_girls = average_height_girls / amount_girls;
printf("Average weight of boys is %d\n", average_weight_boys );
printf("Average height of girls is %d\n", average_height_girls );
printf("Max height of boys is %d\n", max_height_boys);
system("pause");
return 0;
}
3)
#include "stdio.h"
#include "stdlib.h"
#include "fstream"
using namespace std;
int main(){
const int amount_numbers = 10;
char buffer[4];
float mas[amount_numbers];
float temp_number;
ofstream fout("cppstudio.txt", ios_base::out | ios_base::trunc);
for(int i = 0; i < amount_numbers; i++){
printf("Enter number(%d)): ", i + 1); scanf("%f",&temp_number);
fout << temp_number << "\n";</p>
}
fout.close();
ifstream fin("cppstudio.txt", ios_base::in);
for (int i = 0; i < amount_numbers; i++){
fin >> buffer;
float ibuffer = atof(buffer);
mas[i] = ibuffer;
}
fin.close();
float min = mas[0];
float max = mas[0];
for (int i = 1; i < amount_numbers; i++){
if(mas[i] > max){
max = mas[i];
}
if(mas[i] < min){
min = mas[i];
}
}
printf("Max number is %f\n", max);
printf("Min number is %f\n", min);
system("pause");
return 0;
}