Results 1 to 3 of 3

Thread: C++

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Dec:2008
    Location:
    Posts: 438

    C++

    Code:
    #include <stdio.h>
    #include <conio.h>
    
    void main() {
    	float *a, *b, *c, *d, kv;
    	int n, k=0, br=0;
    
    	printf("Zadaite n: "); scanf("%d",&n);
    
    	a = new float[n];
    	b = new float[n];
    	c = new float[n];
    	d = new float[n];
    
    	for (int i=0;i<n;i++) {
    		printf("a[%d]: "); scanf("%d",&n);
    		printf("b[%d]: "); scanf("%d",&n);
    		printf("c[%d]: "); scanf("%d",&n);
    		printf("d[%d]: "); scanf("%d",&n);
    	}
    
    	kv = (a[0]+b[0]+c[0]+d[0])/4;
    
    	for(i=1;i<n;i++) {
    		float usp = (a[i]+b[i]+c[i]+d[i])/4;
    
    		if( usp > kv ) {
    			k = i;
    			kv = usp;
    		}
    	}
    
    	for(i=0;i<n;i++) {
    		if (a[i]>=3 && b[i]>=3 && c[i]>=3 && d[i]>=3 ) {
    			br++;
    		}
    	}
    
    	delete a; delete b; delete c; delete d;
    
    	printf("Studenta s nai-visok uspeh: %f\n",k);
    	printf("Studenti bez dvoiki: %f\n",br);
    	getch();
    }
    a,b,c d, n . - . .

    ? - ?

  2. #2
    Pesho's Avatar
    Join Date: Nov:2001
    Location: Sofia
    Posts: 5,169
    - printf- %f, int- .

    . - debug- , .

    P.S. . n.
    , !

  3. #3
    Registered User hateras's Avatar
    Join Date: Jan:2011
    Location: Kronos III
    Posts: 1,028
    :
    Code:
          printf("a[%d]: "); scanf("%d",&n);
          printf("b[%d]: "); scanf("%d",&n);
          printf("c[%d]: "); scanf("%d",&n);
          printf("d[%d]: "); scanf("%d",&n);
    , - . , ... :-D
    Code:
    float usp = (a[i]+b[i]+c[i]+d[i])/4;
    Pesho :
    Code:
    printf("Studenta s nai-visok uspeh e #%d s uspeh %f\n",k, kv);
    printf("Studenti bez dvoiki: %d\n",br);
    ASRock B550M Pro 4; Ryzen R5 3600; 2x16 GiB G.SKILL Aegis 3200; 1TB Samsung QVO 960 + 3TB Seagate IronWolf; Zalman Z1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |