نصائح و استشارات برمجية
前往频道在 Telegram
• نصائح واستشارات برمجية متعلقة باسئلة تم طرحها • لطرح استفسار او سؤال: @m4md24
显示更多1 443
订阅者
-224 小时
-77 天
+530 天
帖子存档
• تقدر تكتبي كدا ↓
var = sum*sum• او كدا ↓
var = pow(sum, 2)■ للمعلومة عشان تستخدمي دالة الجذر والتربيع لازم تستدعي مكتبة math ↓
#include <math.h>شوف الموقع دا ⬇️:
m3md69.github.io/NULLEXIA
فيه دورات تعليمية لناس بتعرف تشرح .. كل اللي عليك انك تروح لقسم التعلم و تختار اللي عايزه .. الناس اللي بتشرح مختارهم بنفسي
public class SumFinder {
public static void main(String[] args) {
int n = findNumberWithIdenticalDigits();
int sum = calculateSum(n);
System.out.println("The number is " + n + " and the sum from 1 to " + n + " is " + sum);
}
private static int findNumberWithIdenticalDigits() {
int n = 1;
while (true) {
int sum = calculateSum(n);
if (hasIdenticalDigits(sum)) {
return n;
}
n++;
}
}
private static int calculateSum(int n) {
return (n * (n + 1)) / 2;
}
private static boolean hasIdenticalDigits(int number) {
String numberStr = String.valueOf(number);
char digit = numberStr.charAt(0);
for (int i = 1; i < numberStr.length(); i++) {
if (numberStr.charAt(i) != digit) {
return false;
}
}
return true;
}
}
2. Write a Java program that finds a positive integer n such that the sum of all the integers:
1 + 2 + 3 + …. + n is a number between 100 and 1000000 whose two/ three digits are identical. As output, the program displays the integer n and the corresponding sum. Your program MUST be structured into three methods: The main method and two other methods; one to find the sum from 1 to n, and another to prove that the digits are identical
The following is a sample of a possible run:
run:
The number is 22 and the sum from 1 to 22 is 253
The number is 33 and the sum from 1 to 33 is 561
The number is 44 and the sum from 1 to 44 is 990
The number is 55 and the sum from 1 to 55 is 1540
The number is 66 and the sum from 1 to 66 is 2211
The number is 77 and the sum from 1 to 77 is 3003
The number is 88 and the sum from 1 to 88 is 3916
The number is 99 and the sum from 1 to 99 is 4950
The number is 111 and the sum from 1 to 111 is 6216
The number is 222 and the sum from 1 to 222 is 24753
The number is 333 and the sum from 1 to 333 is 55611
The number is 444 and the sum from 1 to 444 is 98790
BUILD SUCCESSFUL (total time: 0 seconds)
ياخي أنا أدرس محاسبه مستوى اول.ومعنا ماده الحاسوب اشتي أفهم في الخوارزميات..ولا فهمت حاجه فيها
حدد اللي عايزو و بعدين اعمل الاختصارة دي، دا لو بتستخدم برنامج من برامج شركة JetBrains⬇️
alt + shift + ctrl + j
• اه ممكن، زي كدا ↓
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
srand(static_cast<unsigned int>(time(0)));
int randomNumber = rand() % 31 + 20;
cout << "Random number between 20 and 50: " << randomNumber << endl;
return 0;
}
现已上线!2025 年 Telegram 研究 — 年度关键洞察 
