2024-12
c_cppa year ago
#include <iostream>
#include <cctype>
#include <cstring>
#include <iomanip>
using namespace std;
char findCapital(char* s, int len)
{
if(isupper(s[0]))
{
return s[0];
}
if(s[0] == s[len-1])
return '\0';
findCapital(s+1, len-1);
}
int main() {
char str[100];
cin.getline(str, 100);
int len = strlen(str);
char res = findCapital(str, len);
if(res == '\0')
cout<<"Nema";
else
cout<<res;
}
2024-11
c_cppa year ago
#include <iostream>
#include <cctype>
#include <cstring>
#include <iomanip>
using namespace std;
int main() {
int m,n;
cin>>m>>n;
int arr[m][n];
int M[m][n];
//input array
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
cin>>arr[i][j];
M[i][j]=arr[i][j];
}
}
int k;
cin>>k;
/*if(k==1)
{
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
cout<<arr[i][j]<<" ";
}
cout<<endl;
}
return 0;
}*/
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
if(i+k -1 < m and j+k - 1 < n)
{
int sum=0;
//left vertical
for(int row = i; row < k+i; row++)
sum+=arr[row][j];
//right vertical
for(int row = i; row < k+i; row++)
sum+=arr[row][j+k-1];
// Suma diagonala
for(int step = 1; step < k - 1; step++) {
sum += arr[i + step][j+step];
}
M[i][j]=sum;
}
}
}
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
cout<<M[i][j]<<" ";
}
cout<<endl;
}
}
2024-10
c_cppa year ago
#include <iostream>
#include <cctype>
#include <cstring>
#include <iomanip>
using namespace std;
bool soglaska(char a)
{
a = tolower(a);
return(a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u');
}
int countItUpPRO(char *s)
{
int count = 0;
int len = strlen(s);
int posledovatelni = 0;
for (int i = 0; i < len;)
{
count = 0;
if(soglaska(s[i]))
{
for(int j = i; soglaska(s[j]); j++)
{
count++;
}
if(count>1)
{
posledovatelni++;
}
i += count;
}
else
i++;
}
return posledovatelni;
}
int main() {
int n;
cin >> n;
cin.ignore();
int results[99] = {0};
char s[101];
int a = 0;
for (int i = 0; i < n; i++) {
cin.getline(s, 101);
int counter = countItUpPRO(s);
results[counter]++;
if (counter > a)
a = counter;
//cout<<s<<" : "<<counter<<endl; //DEBUG
}
for (int i = 0; i <= a; i++) {
cout << i << ": " << results[i] << endl;
}
return 0;
}2024-9
c_cppa year ago
#include <iostream>
#include <cctype>
#include <cstring>
#include <iomanip>
using namespace std;
char findCapital(char* s, int len)
{
if(ispunct(s[0]))
{
return s[0];
}
if(s[0] == s[len-1])
return '\0';
return findCapital(s+1, len - 1);
}
int main() {
char str[100];
cin.getline(str, 100);
int len = strlen(str);
char res = findCapital(str, len);
if(res == '\0')
cout<<"Nema";
else
cout<<res;
}
2024-8
c_cppa year ago
#include <iostream>
#include <cctype>
#include <cstring>
#include <iomanip>
using namespace std;
int main() {
int m,n;
cin>>m>>n;
int arr[m][n];
int M[m][n];
//input array
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
cin>>arr[i][j];
M[i][j]=arr[i][j];
}
}
int k;
cin>>k;
if(k==1)
{
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
cout<<arr[i][j]<<" ";
}
cout<<endl;
}
return 0;
}
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
if(i+k -1 < m and j+k - 1 < n)
{
int sum=0;
//top horizontal
for(int col = j; col < k+j; col++)
sum+=arr[i][col];
//bot horizontala
for(int col = j; col < k+j; col++)
sum+=arr[i+k-1][col];
// Suma diagonala
for(int step = 1; step < k - 1; step++) {
sum += arr[i + step][j + k - 1 - step];
}
M[i][j]=sum;
}
}
}
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
cout<<M[i][j]<<" ";
}
cout<<endl;
}
}