Hirdetés
- Váratlanul megerősítette a mobil GeForce RTX 5070-et az NVIDIA
- A képkockasebességet is tudja mérni az új AIDA64
- Ha tetszik a jó öreg Xbox Green Edition konzol, ez a numerikus pad is fog
- Így viseli a Samsung az okosszemüveget
- ASUS blog: a memóriahiány nem jelenti azt, hogy ne javíthatnánk a PC-s élményen
Új hozzászólás Aktív témák
-
Dirty_Pio
csendes tag
Sziasztok, volna egy kis problemam egy programmal... eleg sok errort kidob, de en nem ertem mia baja. Az errorok a figgvenyekre vonatkoznak nagyreszben, azzal a szoveggel, hogy pl. az elso fuggvenybe x has a forward declaration. A feladat szovege
rite a program to add two large integer numbers of length up to 80 digits (no predefined type offers this range/precision !). One approach is to treat each number as an array of digits. The two integers (arrays) are added element by element, carrying from one element to the next when necessary. Each number is read digit by digit (a loop of getchar() until end of line is encountered) and stored in an array of digits.//program 5.6 (lab)
#define MAX 81
#include <stdio.h>
#include <stdlib.h>
int reading(int x[];int max)
{
int i,c;
while (c=getchar()!=EOF)
{
x[i]=c-'0';
i++;
}
i--;
return i;
}
int add(int a; int b; int r)
{
int s;
s=a+b+r;
return s;
}
int reminder(int a; int b; int r)
{
int s;
s=(a+b+r)/10;
return s;
}
int main(void)
{
int i,j,k,r;
int x[MAX],y[MAX],z[MAX];
i=reading(x,MAX);
j=reading(y,MAX);
r=0;
for (k=0; (k<=i) && (k<=j); k++)
{
z[k]=add(x[k],y[k],r);
r=reminder (x[k],y[k],r);
}
if (i<j) for (k; k<=j; k++)
{
z[k]=add(0,y[k],r);
r=reminder(0,y[k],r);
};
else
for (k; k<=j; k++)
{
z[k]=add(0,x[k],r);
r=reminder (0,x[k],r);
};
z[k++]=r;
for (i=0;i<(k+1);i++)
printf("%i \n",z[i]);
system("pause");
return(0);
}
na asszem megvan a baj... a figgvenybe ; hasznaltam , helyett grrr..
Új hozzászólás Aktív témák
● olvasd el a téma összefoglalót!
● ha kódot szúrsz be, használd a PROGRAMKÓD formázási funkciót!
- Apple iPhone 17 Pro Max 256GB,Újszerű,Adatkabel,12 hónap garanciával
- AKCIÓS!! áthajtós érintős 360 szinteÚJ Dell 16 Plus 2-in-1 Ultra 7 258V Intel Arc 140V 32GB 1TB SSD
- ELADÓ ÚJ 1 HETES, EZÜST Surface Pro 10 Intel Core Ultra 7 165U 16GB RAM 512GB SSD 1 év gar
- Apple iPhone 11 128 GB,Újszerű,Adatkabel,12 hónap garanciával
- AKCIÓ! ASRock A520M R5 4500 8GB DDR4 512GB SSD GTX 1050 Ti 4GB Zalman T3 Plus DeepCool 400W
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
rite a program to add two large integer numbers of length up to 80 digits (no predefined type offers this range/precision !). One approach is to treat each number as an array of digits. The two integers (arrays) are added element by element, carrying from one element to the next when necessary. Each number is read digit by digit (a loop of getchar() until end of line is encountered) and stored in an array of digits.
