Μενου Σουπερ


Breaking News
.

Πέμπτη 9 Ιουλίου 2015

C code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include<stdio.h>
#include<stdlib.h>
int grammiki_anazitisi(double array[],int mege8os,double noumero,int *ptr);
int main(void)
{
 int i,fores,thesi;
 double ari8mos,numero,pinakas[50];
 
 for(i=0; i<50; i++)
 {
  printf("Dose ari8mo\n");
  scanf("%f",&numero);
  if(numero>=0)
  {
   pinakas[i]=numero;
  }
 }
 printf("Dose ari8mo gia anazitisi\n");
 scanf("%f",&ari8mos);
 thesi=grammiki_anazitisi(pinakas,50,ari8mos,&fores);
 if(thesi==-1)
 {
  printf("Den bre8ike o ari8mos %d mesa sto pinaka \n",ari8mos);
 }
 else
 {
  printf("O ari8mos %f emfanizetai stin thesi %d kai mesa ston pinaka emfanizetai %d fores\n",ari8mos,thesi,fores );
  printf("I 8esi tou protou stoixeiou einai : %d",thesi);
 }
system("pause");
return 0;

}

int grammiki_anazitisi(double array[], int mege8os, double noumero, int *ptr)
{
 int i;
 int thesi;
 
 thesi=-1;
 *ptr=0;
 for(i=0; i<mege8os; i++)
 {
  if(array[i]==noumero)
  {
   (*ptr)=(*ptr)+1;
  if(thesi==-1)
  {
   thesi=i;
  } 
  }
 }
 return thesi;
}

Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου

Φόρμα επικοινωνίας

Όνομα

Ηλεκτρονικό ταχυδρομείο *

Μήνυμα *

Designed By Blogger Templates