Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1)
- C++
- #include "stdafx.h"
- #include "iostream"
- using namespace std;
- int main()
- {
- int x[10];
- int a = 0;
- for (int i = 1;i <= 10;i++)
- {
- if (i % 2 == 0)
- {
- x[a] = i;
- a++;
- }
- }
- for (int j = 0;j < a;j++)
- {
- cout << x[j] <<endl;
- }
- system("pause");
- return 0;
- }
- C#
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Zad1_Csharp
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] x = new int[10];
- int a = 0;
- for(int i=1; i<=10;i++)
- {
- if(i%2==0)
- {
- x[a] = i;
- a++;
- }
- }
- for(int j=0; j<a;j++)
- {
- Console.WriteLine(x[j]);
- }
- Console.ReadKey();
- }
- }
- }
- 3)
- C++
- #include "stdafx.h"
- #include "iostream"
- #include "fstream"
- #include "string"
- using namespace std;
- int main()
- {
- string x[5];
- x[0] = "Osnove programiranja";
- x[1] = "Racunalni engleski 1";
- x[2] = "Matematika";
- x[3] = "Uvod u ICT";
- x[4] = "Algoritmi i strukture podataka";
- ofstream oDat;
- oDat.open("D:\\Games\\Kolegiji_polje.txt");
- for (int i = 0; i < 5;i++)
- {
- oDat << x[i] << endl;
- }
- oDat.close();
- return 0;
- }
- C#
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- namespace Zad3_Csharp
- {
- class Program
- {
- static void Main(string[] args)
- {
- string [] x = new string[5];
- x[0] = "Osnove programiranja";
- x[1] = "Racunalni engleski 1";
- x[2] = "Matematika";
- x[3] = "Uvod u ICT";
- x[4] = "Algoritmi i strukture podataka";
- string path = @"D:\Games\Kolegiji_polje2.txt";
- StreamWriter oDat = new StreamWriter(path, true);
- for (int i = 0; i < 5; i++)
- {
- oDat.WriteLine(x[i]);
- }
- oDat.Flush();
- oDat.Close();
- }
- }
- }
- 4)
- C++
- #include "stdafx.h"
- #include "iostream"
- using namespace std;
- int main()
- {
- int brojevi[10];
- for (int i = 0; i < 10;i++)
- {
- cin >> brojevi[i];
- }
- for (int j = 0; j < 10;j++)
- {
- if (j % 2 != 0)
- {
- cout << brojevi[j] << endl;
- }
- }
- system("pause");
- return 0;
- }
- C#
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Zad4_Csharp
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] brojevi = new int[10];
- for(int i=0; i<10;i++)
- {
- brojevi[i] = Convert.ToInt32(Console.ReadLine());
- }
- for (int j = 0; j < 10; j++)
- {
- if (j % 2 != 0)
- {
- Console.WriteLine(brojevi[j]);
- }
- }
- Console.ReadKey();
- }
- }
- }
- 7)
- C#
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Zad7_Csharp
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> x = new List<string>();
- x.Add("B");
- x.Add("C");
- x.Add("A");
- x.Sort();
- foreach (string value in x)
- {
- Console.WriteLine(value);
- }
- Console.ReadKey();
- }
- }
- }
- 8)
- C++
- #include "stdafx.h"
- #include "iostream"
- #include "vector"
- #include "string"
- #include "fstream"
- using namespace std;
- int main()
- {
- vector<string> x;
- x.push_back("Osnove programiranja");
- x.push_back("Racunalni engleski 1");
- x.push_back("Matematika");
- x.push_back("Uvod u ICT");
- x.push_back("Algoritmi i strukture podataka");
- ofstream oDat;
- oDat.open("D:\\Games\\Kolegiji_vektor.txt");
- for (int i = 0; i < x.size();i++)
- {
- oDat << x[i] << endl;
- }
- oDat.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement