Results 1 to 11 of 11
Thread: c++
Hybrid View
-
12th April 2011 19:40 #1Registered User
Join Date: Apr:2011
Location:
Posts: 90
c++
, :
a1,a2,....,an b1,b2...,bn n . () - .
, , - , 2 2 - 100 100
?
#include <stdio.h>
#include <math.h>
#include <conio.h>
void main ()
{
int a[20];
int b[20];
int c[20];
int p[20];
int n;
printf("vavedete broq na triagalnicite"); scanf("%d",&n);
for (int i=0; i<n; i++){
printf("vavedete kateta a"); scanf("%d",&a[i]);
printf("vavedete kateta b"); scanf("%d",&b[i]); }
for (i=0; i<n; i++) {
c[i]=sqrt((a[i]*a[i])+(b[i]*b[i]));
p[i]=a[i]+b[i]+c[i]; }
int maxp=0;
for (i=1; i<n; i++)
if (p[i]>p[maxp]) maxp=i;
printf("nomera na triagalnika s nai golqm perimetar e %d",maxp);
getch();
}
-
12th April 2011 20:18 #2
++ , ++?
|ASUS RoG Z690-E i7-13700k@ 5.6/4.3Ghz + Kraken X63 216GB Kingston Fury Beast 6000hmz 32-40-40-28 | RTX4080 | 256GB 960Evo, 1TB 970Evo, 2x2TB 980Pro, 1TB 860Evo|HX1200|CM MasterCase Pro 5|
|Steam Deck 256GB | 36 TB Unraid NAS| Asus Z87-DELUXE i7-4790K 32GB DDR3|
TengaM#2700 / 7engaM
-
12th April 2011 20:21 #3Registered User
Join Date: Apr:2011
Location:
Posts: 90
C C++
-
12th April 2011 22:00 #4
-
12th April 2011 22:36 #5
, ++, . ,
, ++
|ASUS RoG Z690-E i7-13700k@ 5.6/4.3Ghz + Kraken X63 216GB Kingston Fury Beast 6000hmz 32-40-40-28 | RTX4080 | 256GB 960Evo, 1TB 970Evo, 2x2TB 980Pro, 1TB 860Evo|HX1200|CM MasterCase Pro 5|
|Steam Deck 256GB | 36 TB Unraid NAS| Asus Z87-DELUXE i7-4790K 32GB DDR3|
TengaM#2700 / 7engaM
-
12th April 2011 23:00 #6Registered User
Join Date: Apr:2011
Location:
Posts: 90
- .
Visual c++
-
12th April 2011 23:41 #7Registered User
Join Date: Jul:2004
Location:
Posts: 621
, . :-)
, c[i] p[i] . . , float double, sqrt() .
.. .... , 0? , - , "nomera na triagalnika s nai golqm perimetar e 0"
-
13th April 2011 14:11 #8Registered User
Join Date: Apr:2011
Location:
Posts: 90
... 0
---------- 12:11 ---------- 12:03 ----------
0
1?
-
13th April 2011 14:14 #9Registered User
Join Date: Jul:2004
Location:
Posts: 621
+1 "":
Code:printf("nomera na triagalnika s nai golqm perimetar e %d",maxp + 1);
-
13th April 2011 23:38 #10Game programmer
Join Date: Feb:2007
Location:
Posts: 1,948
-
17th April 2011 14:48 #11Registered User
Join Date: Apr:2011
Location:
Posts: 90
- ,
#include <stdio.h>
#include <math.h>
#include <conio.h>
void main ()
{
int n;
printf("vavedete broq na triagalnicite: "); scanf("%d",&n);
float *a=new float[n];
float *b=new float[n];
float *c=new float[n];
float *p=new float[n];
for (int i=0; i<n; i++){
printf("\nvavedete kateta a na %d-i: ",i+1); scanf("%f",&a[i]);
printf("vavedete kateta b na %d-i: ",i+1); scanf("%f",&b[i]); }
for (i=0; i<n; i++) {
c[i]=sqrt((a[i]*a[i])+(b[i]*b[i]));
p[i]=a[i]+b[i]+c[i]; }
int ind_max=0;
for (i=0; i<n; i++)
if (p[i]>p[ind_max]) ind_max=i;
printf("\nnai golqm perimetar imat triagalnika/cite s nomer:\n");
for (i=ind_max; i<n; i++)
if (p[i]==p[ind_max]) printf("%d\n",i+1);
getch();
delete []a;
delete []b;
delete []c;
delete []p;
}




Reply With Quote

Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in