Ú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!
- Szép! Lenovo Thinkpad T14 G3 Golyóálló Üzleti Érintős Laptop 14" -50% i5-1250P 12Mag 16GB/512GB FHD+
- Lenovo ThinkPad L480 i5-7300u / 14" FHD IPS / 8GB / 256GB m.2 SSD / jó akku /
- PRÉMIUM WHITE PC - 9800X3D / 9070 XT Hellhound Spectral White OC / ASRock X670E Taichi Carrara (L)
- Apple iPhone 15 Pro 128GB, Kártyafüggetlen, 1 Év Garanciával
- Asus ROG Strix G16 Notebook! i9-14900HX / RTX 4060 / 16GB DDR5 / 1TB NVMe! BeszámítOK
- Új és újszerű 15-16 Gamer, irodai, üzleti, készülékek nagyon kedvező alkalmi áron Garanciával!
- Microsoft Surface Pro 9 i5-1245U 16GB 512GB 1 év garancia
- PlayStation 5 FAT Lemezes + kontroller 6 hó garancia, számlával!
- Samsung Galaxy S21 Ultra 5G / 12/256GB / Kártyafüggetlen / 12Hó Garancia
- Xiaomi Redmi Note 14 Pro+ / 8/256GB / Kártyafüggetlen / 12Hó Garancia
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
Cég: NetGo.hu Kft.
Város: Gödöllő

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.

