This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <fstream.h> | |
void main() { | |
ifstream f("nr1.txt"), g("nr2.txt"); | |
int x, y, n, m, i, j; | |
f >> n; | |
g >> m; | |
i = j = 1; | |
f >> x; | |
g >> y; | |
while (i <= n && j <= m) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream.h> | |
void nule(int n, int a[100]) { | |
int i, aux; | |
for (i = 1; i < n; i++) | |
if (a[i] == 0 && a[i + 1] != 0) { | |
aux = a[i]; | |
a[i] = a[i + 1]; | |
a[i + 1] = aux; | |
if (i > 1) | |
i = i - 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream.h> | |
#include <string.h> | |
void main() { | |
char s[251], i; | |
cin.get(s, 251); | |
for (i = 0; i < strlen(s) - 1; i++) | |
if (s[i] == s[i + 1] && s[i] != '*') | |
cout << s[i] << s[i + 1] << endl; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream.h> | |
int prim(int n) { | |
if (n == 0 || n == 1) | |
return 0; | |
for (int i = 2; i <= n / 2; i++) | |
if (n % i == 0) | |
return 0; | |
return 1; | |
} | |
int i_prim(int n) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <fstream.h> | |
ifstream f("bac.txt"); | |
void main() { | |
int n, k, i, j, imax, s = 0, smax, x[10000], y, p; | |
f >> n >> k; | |
for (i = 1; i <= k; i++) { | |
f >> x[i]; | |
s = s + x[i]; | |
} | |
imax = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <conio.h> | |
#include <iostream.h> | |
void main() { | |
int n, m, k = 1, i, j; | |
cin >> m >> n; | |
int a[25][25]; | |
k = m * n; | |
for (i = 1; i <= m; i++) | |
for (j = 1; j <= n; j++) | |
a[i][j] = k--; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <fstream.h> | |
ifstream f("bac.txt"); | |
int a, b, n; | |
int p2(int n) { | |
int p = 1; | |
while (p <= n) | |
p = p * 2; | |
return p / 2; | |
} | |
void main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <fstream> | |
#include <iostream> | |
using namespace std; | |
int main() { | |
int n, a[1000], b[1000], i, j, k; | |
ifstream fin("bac.txt"); | |
fin >> n; | |
for (i = 1; i <= n; i++) | |
fin >> a[i] >> b[i]; | |
for (i = 1; i <= n; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <fstream.h> | |
fstream f("matrice.in", ios::in); | |
fstream g("matrice.out", ios::out); | |
int n, m, a[100][100]; | |
void citire() { | |
f >> n >> m; | |
for (int i = 1; i <= n; i++) | |
for (int j = 1; j <= m; j++) | |
f >> a[i][j]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream.h> | |
int n, k, a[100]; | |
void f(int n, int a[100], int &k) { | |
k = 0; | |
int g = 0; | |
for (int i = n - 1; i >= 0; i--) | |
if (a[i] % 2 == 0) { | |
k = k * 10 + a[i]; | |
g++; | |
} |