Hirdetés
- Soundbar, soundplate, hangprojektor
- Kormányok / autós szimulátorok topikja
- Milyen billentyűzetet vegyek?
- Kegyvesztett lehet a Radeon termékskála középső tagja
- AMD K6-III, és minden ami RETRO - Oldschool tuning
- Projektor topic
- Apple MacBook
- Milyen asztali (teljes vagy fél-) gépet vegyek?
- HDD probléma (nem adatmentés)
- Dell notebook topic
Ú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!
- iPhone 15 Pro Max Natúr Titán 256 GB
- 2 db FSP Champ Tower 3000VA szünetmentes tápegység (PPF24A1807) eladó
- Samsung Galaxy S11 Ultra 14.6 512GB wifi
- Bomba Ár! Lenovo ThinkPad P53 - i7-9850H I 64GB I 1TBSSD I FHD I Nvidia 4GB I W11 I Cam I Garancia!
- Bomba Ár! Lenovo ThinkPad P52 - i7-8850H I 16GB I 512SSD I FHD I Nvidia 4GB I W11 I Cam I Garancia!
- BESZÁMÍTÁS! Sapphire B650M R5 7500F 32GB DDR5 1TB SSD RTX 3080 10GB Lian LI LANCOOL 207 FSP 750W
- Microsoft Surface Laptop 3 13.5" fekete i5-1035G7 16GB 512GB 1 év garancia
- Apple iPhone 14 Pro 512GB, Kártyafüggetlen, 1 Év Garanciàval
- TP Link HS100 Távolról vezérelhető Wi-Fi-s dugalj (Smart Plug)
- Samsung Galaxy S24 Ultra 512GB Kártyafüggetlen 1év Garanciával
Állásajánlatok
Cég: Central PC számítógép és laptop szerviz - Pécs
Város: Pécs
Cég: PCMENTOR SZERVIZ KFT.
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.

