SlideShare a Scribd company logo
#include<iostream>
#include<conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
using namespace std;
int main()
{
int i,j,l;
int tsc=12;
float bat_ave[12]={25,28,34,38,5,6,10,9,48,55,50,58};
float bowl_ave[12]={30,32,33,37,25,22,19,17,100,110,90,105};
char cat[12]
[15]={"all_rounder","all_rounder","all_rounder","all_rounder","bowler","bowler",
"bowler","bowler","batsman","batsman","batsman","batsman"};
cout<<"n Initial Set:";
cout<<"nbatting_avetwicket_avetOutput";
for(i=0;i<12;i++)
{
cout<<"n"<<bat_ave[i]<<"t"<<bowl_ave[i]<<"t"<<cat[i];
}
int bowl_a;
int bat_a;
cout<<"n Enter the player batting average :";
cin>>bat_a;
cout<<"n Enter the player bowling average :";
cin>>bowl_a;
int k;
cout<<"n Enter the value of 'k':";
cin>>k;
float d[12][2],t ;
float c[12][2],m;
float e[12][2],f[12][2];
//calculating distance to each value in training set
for(i=0;i<12;i++)
{
f[i][0]=i;
t=bowl_ave[i]-bowl_a;
m=bat_ave[i]-bat_a;
d[i][1]=t*t;
c[i][1]=m*m;
e[i][1]=d[i][1]+c[i][1];
f[i][1]=sqrt(e[i][1]);
}
cout<<"full distance"<<endl;
for(i=0;i<12;i++){
cout<<f[i][1]<<endl;
}
//Sorting
for(i=0;i<11;i++)
{
for(j=0;j<11;j++)
{
if(f[j][1]>f[j+1][1])
{
t=f[j][1];
f[j][1]=f[j+1][1];
f[j+1][1]=t;
l=f[j][0];
f[j][0]=f[j+1][0];
f[j+1][0]=l;
}
}
}
cout<<"in sorting"<<endl;
for(i=0;i<12;i++){
cout<<f[i][1]<<endl;
}
cout<<"numbersss"<<endl;
for(i=0;i<12;i++){
cout<<f[i][0]<<endl;
}
int no_all=0; //no of allrounder
int no_bat=0; //no of batsman
int no_bowl=0; //no of bowlers
cout<<"nbattingtbowlingtOutputn";
for(i=0;i<k;i++)
{
l=f[i][0];
cout<<bat_ave[l]<<"t"<<bowl_ave[l]<<"t"<<cat[l]<<"n";
if(strcmp(cat[l],"all_rounder")==0)
{
no_all++;
}
if(strcmp(cat[l],"batsman")==0)
{
no_bat++;
}
if(strcmp(cat[l],"bowler")==0)
{
no_bowl++;
}
}
cout<<"n No of allrouder:"<<no_all;
cout<<"n No of batsman:"<<no_bat;
cout<<"n No of bowler:"<<no_bowl;
if(no_all>no_bat&&no_all>no_bowl)
{
cout<<"n the new player is classified as allrounder"<<endl;
}
if(no_bat>no_all&&no_bat>no_bowl)
{
cout<<"n the new player is classified as batsman"<<endl;
}
if(no_bowl>no_bat&&no_bowl>no_all)
{
cout<<"n the new player is classified as bowler"<<endl;
}
getch();
}

More Related Content

PDF
מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה
PDF
大量地区化解决方案V5
PPTX
Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming
PPTX
Hello c
PDF
An Introduction to Tinkerpop
PPTX
Introduzione a C#
מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה
大量地区化解决方案V5
Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming
Hello c
An Introduction to Tinkerpop
Introduzione a C#

What's hot (20)

PDF
PDF
Clustering com numpy e cython
TXT
Programação completa e perfeira
PDF
JavaScript Code Formatting With Prettier by Christopher Chedeau
PPTX
PDF
Linux tips
PDF
3分くらいで分かるassert()
PDF
Drawing on canvas
DOCX
Programming assignment 30 12-11
DOCX
Abebe1
PDF
TypeScript 101
PDF
メディアアートにおけるプログラミング言語Rubyの役割
TXT
New text document
DOCX
สุภาษิตล้านนา
PPTX
CBSE, Grade12, Computer Science, Random Numbers - Notes
PPT
Shell and perl scripting classes in mumbai
PDF
The Ring programming language version 1.5.2 book - Part 51 of 181
Clustering com numpy e cython
Programação completa e perfeira
JavaScript Code Formatting With Prettier by Christopher Chedeau
Linux tips
3分くらいで分かるassert()
Drawing on canvas
Programming assignment 30 12-11
Abebe1
TypeScript 101
メディアアートにおけるプログラミング言語Rubyの役割
New text document
สุภาษิตล้านนา
CBSE, Grade12, Computer Science, Random Numbers - Notes
Shell and perl scripting classes in mumbai
The Ring programming language version 1.5.2 book - Part 51 of 181
Ad

Similar to C code (20)

TXT
Bubble archery game(c program)
TXT
Bubble archery game(c program)
RTF
project3
DOC
Daapracticals 111105084852-phpapp02
DOCX
Os lab file c programs
TXT
Simulador carrera de caballos desarrollado en C++
PDF
C program
PPTX
4. chapter iii
PPTX
Library functions in c++
DOCX
code (1) thông tin nhập môn cntt hdsd.docx
PDF
Look Ma, “update DB to HTML5 using C++”, no hands! 
PDF
2 BytesC++ course_2014_c4_ arrays
DOCX
Cd practical file (1) start se
PDF
54602399 c-examples-51-to-108-programe-ee01083101
PDF
Programming Fundamentals Arrays and Strings
PDF
Os lab upto_1st_mid
PDF
Os lab 1st mid
PDF
Os lab upto 1st mid
PDF
C programms
Bubble archery game(c program)
Bubble archery game(c program)
project3
Daapracticals 111105084852-phpapp02
Os lab file c programs
Simulador carrera de caballos desarrollado en C++
C program
4. chapter iii
Library functions in c++
code (1) thông tin nhập môn cntt hdsd.docx
Look Ma, “update DB to HTML5 using C++”, no hands! 
2 BytesC++ course_2014_c4_ arrays
Cd practical file (1) start se
54602399 c-examples-51-to-108-programe-ee01083101
Programming Fundamentals Arrays and Strings
Os lab upto_1st_mid
Os lab 1st mid
Os lab upto 1st mid
C programms
Ad

Recently uploaded (20)

PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
How Tridens DevSecOps Ensures Compliance, Security, and Agility
PDF
Digital Systems & Binary Numbers (comprehensive )
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PPTX
Cybersecurity: Protecting the Digital World
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
PDF
Website Design Services for Small Businesses.pdf
PDF
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
GSA Content Generator Crack (2025 Latest)
PDF
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
PPTX
Tech Workshop Escape Room Tech Workshop
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
Topaz Photo AI Crack New Download (Latest 2025)
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PDF
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
Complete Guide to Website Development in Malaysia for SMEs
Why Generative AI is the Future of Content, Code & Creativity?
How Tridens DevSecOps Ensures Compliance, Security, and Agility
Digital Systems & Binary Numbers (comprehensive )
Oracle Fusion HCM Cloud Demo for Beginners
Cybersecurity: Protecting the Digital World
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
Website Design Services for Small Businesses.pdf
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
How to Use SharePoint as an ISO-Compliant Document Management System
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
GSA Content Generator Crack (2025 Latest)
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
Tech Workshop Escape Room Tech Workshop
Computer Software and OS of computer science of grade 11.pptx
Topaz Photo AI Crack New Download (Latest 2025)
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Complete Guide to Website Development in Malaysia for SMEs

C code

  • 1. #include<iostream> #include<conio.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> using namespace std; int main() { int i,j,l; int tsc=12; float bat_ave[12]={25,28,34,38,5,6,10,9,48,55,50,58}; float bowl_ave[12]={30,32,33,37,25,22,19,17,100,110,90,105}; char cat[12] [15]={"all_rounder","all_rounder","all_rounder","all_rounder","bowler","bowler", "bowler","bowler","batsman","batsman","batsman","batsman"}; cout<<"n Initial Set:"; cout<<"nbatting_avetwicket_avetOutput"; for(i=0;i<12;i++) { cout<<"n"<<bat_ave[i]<<"t"<<bowl_ave[i]<<"t"<<cat[i]; } int bowl_a; int bat_a; cout<<"n Enter the player batting average :"; cin>>bat_a; cout<<"n Enter the player bowling average :"; cin>>bowl_a; int k; cout<<"n Enter the value of 'k':"; cin>>k; float d[12][2],t ; float c[12][2],m; float e[12][2],f[12][2]; //calculating distance to each value in training set for(i=0;i<12;i++) { f[i][0]=i; t=bowl_ave[i]-bowl_a; m=bat_ave[i]-bat_a; d[i][1]=t*t; c[i][1]=m*m; e[i][1]=d[i][1]+c[i][1]; f[i][1]=sqrt(e[i][1]); } cout<<"full distance"<<endl; for(i=0;i<12;i++){ cout<<f[i][1]<<endl; } //Sorting for(i=0;i<11;i++) { for(j=0;j<11;j++) {
  • 2. if(f[j][1]>f[j+1][1]) { t=f[j][1]; f[j][1]=f[j+1][1]; f[j+1][1]=t; l=f[j][0]; f[j][0]=f[j+1][0]; f[j+1][0]=l; } } } cout<<"in sorting"<<endl; for(i=0;i<12;i++){ cout<<f[i][1]<<endl; } cout<<"numbersss"<<endl; for(i=0;i<12;i++){ cout<<f[i][0]<<endl; } int no_all=0; //no of allrounder int no_bat=0; //no of batsman int no_bowl=0; //no of bowlers cout<<"nbattingtbowlingtOutputn"; for(i=0;i<k;i++) { l=f[i][0]; cout<<bat_ave[l]<<"t"<<bowl_ave[l]<<"t"<<cat[l]<<"n"; if(strcmp(cat[l],"all_rounder")==0) { no_all++; } if(strcmp(cat[l],"batsman")==0) { no_bat++; } if(strcmp(cat[l],"bowler")==0) { no_bowl++; } } cout<<"n No of allrouder:"<<no_all; cout<<"n No of batsman:"<<no_bat; cout<<"n No of bowler:"<<no_bowl; if(no_all>no_bat&&no_all>no_bowl) { cout<<"n the new player is classified as allrounder"<<endl; } if(no_bat>no_all&&no_bat>no_bowl) { cout<<"n the new player is classified as batsman"<<endl; } if(no_bowl>no_bat&&no_bowl>no_all) { cout<<"n the new player is classified as bowler"<<endl;